Neatest way to do a case insensitive "in"?
marduk at letterboxes.org
Thu Mar 19 23:19:22 CET 2009
On Fri, 2009-03-20 at 08:52 +1100, Jervis Whitley wrote:
> On Fri, Mar 20, 2009 at 8:28 AM, Albert Hopkins <marduk at letterboxes.org> wrote:
> > On Fri, 2009-03-20 at 07:25 +1100, Jervis Whitley wrote:
> >> >
> >> > if stringA.lower() in stringB.lower():
> >> > bla bla bla
> >> >
> >> from string import lower
> >> if lower(stringA) in lower(stringB):
> >> # was this what you were after?
> > This is analogous to standing behind a perfectly functioning automobile
> > and pushing it everywhere you want to go.
> It is an alternative solution. That is all.
I agree that it's an alternative. There are a number of alternatives.
However the OP was asking for a "neater/easier" alternative. I argue
that introducing an external module/function to do the exact same thing
as a built-in type's method doesn't exactly qualify as a "neater/easier"
In fact, unless you are using a *very* old version of python, if you
look at the implementation of string.lower(s) it simply returns
More information about the Python-list