unicode keys in dicts

Jeff Epler jepler at unpythonic.net
Thu Jan 8 10:00:13 EST 2004


>>> chr(0xe9) == unichr(0xe9)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
UnicodeError: ASCII decoding error: ordinal not in range(128)

unequal objects can hash to the same value.  Your two keys are not
equal (in fact, you can't even compare them on my system).  They would
be comparable but not equal on many systems, for instance one where the
system's encoding is Microsoft's CP850.

You can misconfigure your system to assume that byte strings are in (eg)
iso-8859-1 encoding by changing site.py.

Jeff




More information about the Python-list mailing list