"str.contains(part)" or alternatives?

Delaney, Timothy tdelaney at avaya.com
Thu Sep 12 19:09:14 EDT 2002

> From: Stefan Schwarzer [mailto:sschwarzer at sschwarzer.net]
> Thank you (and all others) for their answers. I didn't expect 
> to get so many.
> Btw, Greg, the .count approach is much nicer than ".find != -1".

The .count approach can also be considerably slower - it must scan the
entire string, rather than being able to stop when it first finds a match.

Tim Delaney

More information about the Python-list mailing list