Case-insensitive string compare?
rcdailey at gmail.com
Fri Sep 5 01:48:55 CEST 2008
On Thu, Sep 4, 2008 at 5:59 PM, Maric Michaud <maric at aristote.info> wrote:
> Le Friday 05 September 2008 00:47:00 Chris Rebert, vous avez écrit :
> > Then store the string in its original case in the value part of the
> > key-value pair:
> > stage_map[key.lower()] = (key,whatever)
> "premature optimization is the root of all evil"
> I don't recall the OP wanted a (a bit) faster solution to his problem in
> counterpart of memory loss and syntax complication.
> If the OP's proposal seems already messy, how about ths one :
> if lib.lower() not in ( e for e in stage_map.items() ) :
Thanks everyone for your help. I'm not opposed to using [key.lower() for key
in stage_map] at all, I was just curious to see if there were any cleaner
alternatives. It looks like that is what I'll be using. I'm not familiar
with how python works internally, but coming from C++ it seems like
"remaking" the map would be slow. However, speed is not my main concern in
my particular situation, I'm just curious to learn more about python.
Thanks again everyone.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list