Why KeyError ???

Ozren Lasic ozren_lasic at yahoo.com
Wed Mar 6 19:30:35 CET 2002


Sorry, but I didn't get it.
Maybe you can explain me on another example??

	a = ['abcde', '\xe7\xd0\x9f\x86\xa7']
	b = map(lambda x: unicode(x, 'cp1250'), a)
	c = {}
	c[a[0]] = 0 # string
	c[b[0]]     # unicode
0
	c[a[1]] = 1 # string
	c[b[1]]     # unicode
KeyError
	c[b[0]] = 2 # string
	c[b[1]] = 3 # unicode
	c.keys() # no u'abcde' !! why ??
[u'\u0161\u0111\u010d\u0107\u017e', 'abcde', '\xe7\xd0\x9f\x86\xa7']
        c.vaules()
[3, 2, 1]

Thanks !!



More information about the Python-list mailing list