case insensitive dictionary

John Henry john106henry at hotmail.com
Mon Nov 27 21:36:23 CET 2006


I believe that if you redefine the value, the key should not change.
So, yes, I would expect that they value of the key to remain as they
were.


J. Clifford Dyer wrote:
> 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