Re: unicode by default
- From: Ben Finney <ben+python@xxxxxxxxxxxxxxx>
- Date: Thu, 12 May 2011 14:07:08 +1000
MRAB <python@xxxxxxxxxxxxxxxxxxx> writes:
You need to understand the difference between characters and bytes.
Yep. Those who don't need to join us in the third millennium, and the
resources pointed out in this thread are good to help that.
A string contains characters, a file contains bytes.
That's not true for Python 2.
I'd phrase that as:
* Text is a sequence of characters. Most inputs to the program,
including files, sockets, etc., contain a sequence of bytes.
* Always know whether you're dealing with text or with bytes. No object
can be both.
* In Python 2, ‘str’ is the type for a sequence of bytes. ‘unicode’ is
the type for text.
* In Python 3, ‘str’ is the type for text. ‘bytes’ is the type for a
sequence of bytes.
--
\ “I went to a garage sale. ‘How much for the garage?’ ‘It's not |
`\ for sale.’” —Steven Wright |
_o__) |
Ben Finney
.
- Follow-Ups:
- Re: unicode by default
- From: harrismh777
- Re: unicode by default
- References:
- unicode by default
- From: harrismh777
- Re: unicode by default
- From: Ian Kelly
- Re: unicode by default
- From: harrismh777
- Re: unicode by default
- From: John Machin
- Re: unicode by default
- From: harrismh777
- Re: unicode by default
- From: MRAB
- unicode by default
- Prev by Date: Re: lightweight way to create new projects from templates
- Next by Date: Re: unicode by default
- Previous by thread: Re: unicode by default
- Next by thread: Re: unicode by default
- Index(es):
Relevant Pages
|