Testing if string contains a substring

Frantisek Fuka fuka at fuxoft.cz
Wed Apr 23 09:44:57 EDT 2003


I want a simple test to see if str contains any occurences of substr. I 
am currently using this:

import string
if string.find(str,substr) + 1:
     ...do something...

But it somehow looks "ugly" to me. Is there more "standard" way to test 
this?





More information about the Python-list mailing list