Case-insensitive string comparison

Duncan Booth duncan at NOSPAMrcp.co.uk
Wed Apr 16 13:17:26 CEST 2003


Dale Strickland-Clark <dale at riverhall.NOTHANKS.co.uk> wrote in 
news:d7aq9v0a5ecoue90gccfos9jtkkqcr73di at 4ax.com:

> This is a class you use in place of a string and it emulates a string
> in all practical ways except that comparisons and lookups are case
> insensitive. All uses of the string for assignments, however, yield
> the original case.

I'm slightly surprised that your class doesn't include:

    def lower(self):
        return self.____lowerCaseMe

A quick timing test indicates that this does make a difference.

-- 
Duncan Booth                                             duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?




More information about the Python-list mailing list