Why KeyError ???

Ozren Lasic ozren_lasic at yahoo.com
Tue Mar 5 21:43:20 EST 2002


Why KeyError ???.

Microsoft(R) Windows NT(TM)
(C) Copyright 1985-1996 Microsoft Corp.

C:\>python -S
Python 2.1.2 (#31, Jan 15 2002, 17:28:11) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.setdefaultencoding("cp1250")
>>> a = "\xe7\xd0\x9f\x86\xa7" # Croatian characters
>>> b = unicode(a)
>>> b
u'\xe7\u0110\u017a\u2020\xa7'
>>> c = {}
>>> c[a] = 1
>>> c[b]
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
KeyError: šđčćž
>>> a == b
1

Thanks !!!



More information about the Python-list mailing list