comparing Unicode and string

Neil Cerutti horpner at yahoo.com
Fri Nov 10 08:17:35 EST 2006


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.

-- 
Neil Cerutti
To succeed in the world it is not enough to be stupid, you must also
be well-mannered. --Voltaire



More information about the Python-list mailing list