Case-insensitive string compare?

Robert Dailey rcdailey at
Fri Sep 5 00:15:16 CEST 2008

On Thu, Sep 4, 2008 at 5:14 PM, Robert Dailey <rcdailey at> wrote:

> Hi,
> 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.

I forgot to mention that I'm using Python 3.0 beta 2.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list