case insensitive dictionary

J. Clifford Dyer webmaster at cacradicalgrace.org
Mon Nov 27 14:41:29 EST 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?

Cheers,
Cliff



More information about the Python-list mailing list