Case insensitive dictionary?

Pierre-Frédéric Caillaud peufeu at free.fr
Fri Jun 25 20:04:04 CEST 2004


insert and access your keys with :

mydict[ mykey.lower() ] = value

you can also create a subclass of dict to do this for you.


On 25 Jun 2004 10:21:21 -0700, Elbert Lev <elbertlev at hotmail.com> wrote:

> Hi!
>
> Here is the problem:
>
> I have a dictionary. Keys are strings. How to make dictionary  lookup
> case insensitive?
>
> In other words:
> If dict = {'First":"Bob", "Last":"Tom"}, dict["first"] should return
> "Bob"
>
> Maybe dictionary is not the right data type? If so what is?



-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/



More information about the Python-list mailing list