comparing Unicode and string

Steve Holden steve at holdenweb.com
Fri Nov 10 13:25:02 EST 2006


Neil Cerutti wrote:
> On 2006-11-10, luc.saffre at gmail.com <luc.saffre at gmail.com> wrote:
>> Marc 'BlackJack' Rintsch wrote:
>>> Why?  Python strings are *byte strings* and bytes have values in the range
>>> 0..255.  Why would you restrict them to ASCII only?
>> Because getting an exception when comparing a string with a unicode
>> string is irritating.
>>
>> But I don't insist on my PEP. The example just shows just
>> another pitfall with Unicode and why I'll advise to any
>> beginner: Never write text constants that contain non-ascii
>> chars as simple strings, always make them Unicode strings by
>> prepending the "u".
> 
> That doesn't do any good if you aren't writing them in unicode
> code points, though.
> 
You tell the interpreter what encoding your source code is in. It then 
knows precisely how to decode your string literals into Unicode. How do 
you write things in "Unicode code points"?

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd          http://www.holdenweb.com
Skype: holdenweb       http://holdenweb.blogspot.com
Recent Ramblings     http://del.icio.us/steve.holden




More information about the Python-list mailing list