case insensitive dictionary

J. Clifford Dyer webmaster at
Mon Nov 27 20:41:29 CET 2006

John Henry wrote:
>    print pets.keys()
> should print:
> "Cat", "Dog"

If you do:

Py> pets['Cat'] = 2
Py> pets['Dog'] = 3
Py> pets['DOG'] = 4
Py> pets['cat'] += 5
Py> pets.keys()

What should the result be?

"['Cat', 'Dog']" or "['cat', 'DOG']"?

That is to say, if you use a new case in redefining the values of your
case insensitive dictionary, does the key take on the new case, or will
it always and forever be the case originally given to it?


More information about the Python-list mailing list