case insensitive comparison operator ?

Will McGugan news at nospamwillmcgugan.com
Wed Aug 18 06:33:03 EDT 2004


What is the best way to do a simple case insensitive comparison in Python?

As far as I can tell, the only option is to do str1.lowercase() == 
str2.lowercase() (or uppercase). But that strikes me as quite verbose 
for such a common operation, and possibly inneficient since it would 
create and destroy 2 tempory objects. Perhaps there should be a 
dedicated function in the string object, or (+1) an operator?

Apologies if I have missed something. I haven't done a great deal of 
work int Python yet.


Will McGugan



More information about the Python-list mailing list