unicode keys in dicts

Jiba jiba at tuxfamily.org
Thu Jan 8 15:08:35 CET 2004

Hi all,

is the following behaviour normal :

>>> d = {"é" : 1}
>>> d["é"]
>>> d[u"é"]
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
KeyError: u'\xe9'

it seems that "é" and u"é" are not considered as the same key (in Python
2.3.3). Though they have the same hash code (returned by hash()).

And "e" and u"e" (non accentuated characters) are considered as the same


More information about the Python-list mailing list