Case-insensitive string compare?

Robert Dailey rcdailey at
Fri Sep 5 00:14:37 CEST 2008


I currently have a dictionary object that I'm doing the following with:

if lib not in stage_map:
    # ... do stuff ...

However, this will perform a case-sensitive comparison between lib and each
key in stage_map. Is there a way to make this do a case-insensitive
comparison instead? Yes, I realize I could do this:

if lib not in [key.lower() for key in stage_map]

However, I don't want to do this because it'll quickly end up getting messy.
I want this solution to be an absolute last resort. I'm not a pro with
python, so I'm hoping there are cleaner alternatives out there. Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list