MyHaz wrote:
> OK i find this a quark in string.find that i think needs some
> consideration.
You shouldn't use the module string anymore, instead use string-methods.
> Normally if a substring is not in the searched_string then string.find
> returns -1 (why not len(searched_string) + 1, i don't know but
Because then you need to know how large that string is. That makes the
case-distinction much easier - as -1 can never be the position of a
substring.
Besides, a value of len(haystack) + 1 says "The needle is beyond that
string" - which is bogus.
> nevermind that) but what if a searched_string == '' ? Then
> string.find(substring,searched_string) == 0 ?
>>> "".find("fooob")
-1
as expected. Which python version do you use?
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list