Neatest way to do a case insensitive "in"?

tinnews at isbd.co.uk tinnews at isbd.co.uk
Fri Mar 13 17:49:12 EDT 2009


Albert Hopkins <marduk at letterboxes.org> wrote:
> On Fri, 2009-03-13 at 21:04 +0000, tinnews at isbd.co.uk wrote:
> > What's the neatest way to do the following in case insensitive fashion:-
> > 
> >     if stringA in stringB:
> >         bla bla bla
> > 
> > I know I can just do:-
> > 
> >     if stringA.lower() in stringB.lower():
> >         bla bla bla
> > 
> > But I was wondering if there's a neater/easier way?
> 
> How is "if stringA.lower() in stringB.lower():" complex/messy?
> 
Well I guess I was just looking for "incase" a bit like "strcasecmp"
in C.

-- 
Chris Green



More information about the Python-list mailing list