String comparison

Matt Gerrans matt_gerrans at hp.com
Wed Aug 21 20:02:23 EDT 2002


Nice metaphor -- a good chuckle...

By the way, what is the Pythonic way of doing case-insensitive string
comparisions?    I've been in the habit of doing something like this:

if s1.lower() == s2.lower():
   blah()

I suppose this would do the trick, too:

if re.match( '^' + s1 + '$', s2, re.I ):
   blah()

I'm not sure which of these is better (or maybe it is neither!), though, so,
of course, I'd like to know what the One True Path is...





More information about the Python-list mailing list