oddness in string.find(sub,somestring)

Max M maxm at mxm.dk
Wed Mar 30 13:59:30 CEST 2005


MyHaz wrote:

> why would this be? And when is someone going to fix it :P

Whoops ... This missed the previous message together with the wink ...

  ;-)

"When *are* you going to fix it ..."

substring="123"

import string
searched_string="abcdefg"
print string.find(searched_string, substring) # note the order

searched_string=""
print string.find(searched_string, substring)

You will not make that error if you use the string method instead.

searched_string.find(substring)

And you don't have to import anything either..

-- 

hilsen/regards Max M, Denmark

http://www.mxm.dk/
IT's Mad Science



More information about the Python-list mailing list