Have to try

Jason Orendorff jason at jorendorff.com
Sat Feb 16 23:07:31 EST 2002

Rick Hamilton writes:
> I want to search that string for the occurrence of a sub string.
> I have tried 
> Find(s,sub)
> Rfind
> MyString.find(sub)

It looks like you're using an extra-old version of Python,
because mystring.find(sub) really should work.

>>> x = "lovely spam, wonderful spam!"
>>> x.find('spam')
>>> x.find('food')

So you must be using Python 1.6 or earlier.  Try this.

>>> import string
>>> string.find(x, 'spam')

## Jason Orendorff    http://www.jorendorff.com/

More information about the Python-list mailing list