Is this safe? (Making string comparisons ignore case)

Matthew Cline matt at nightrealms.com
Mon Jun 26 22:23:30 EDT 2000


I've done the following to make it so that all string comparisons
are case insenstive.  Is this safe?  (I'm pleasently surprised that
it actually works)

Thanks in advance.

================================================================
import string

string.__builtins__['oldcmp'] = string.__builtins__['cmp']

oldCmp = string.__builtins__['oldcmp']


def myCmp(self, other):
	return oldCmp(string.lower(self), string.lower(other))

string.__builtins__['cmp'] = myCmp

print cmp("AAAA", "aaaa")







More information about the Python-list mailing list