oddness in string.find(sub,somestring)
From: MyHaz (support.services.complaints_at_gmail.com)
Date: 03/30/05
- Next message: Diez B. Roggisch: "Re: oddness in string.find(sub,somestring)"
- Previous message: Franz Steinhäusler: "PyQt on Python 2.4"
- Next in thread: Diez B. Roggisch: "Re: oddness in string.find(sub,somestring)"
- Reply: Diez B. Roggisch: "Re: oddness in string.find(sub,somestring)"
- Reply: Fredrik Lundh: "Re: oddness in string.find(sub,somestring)"
- Reply: Max M: "Re: oddness in string.find(sub,somestring)"
- Reply: Max M: "Re: oddness in string.find(sub,somestring)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 30 Mar 2005 03:43:49 -0800
OK i find this a quark in string.find that i think needs some
consideration.
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
nevermind that) but what if a searched_string == '' ? Then
string.find(substring,searched_string) == 0 ?
example:
>>> import string
>>> searched_string="abcdefg"
>>> substring="123"
>>> print string.find(substring,searched_string)
-1
>>> searched_string=""
>>> print string.find(substring,searched_string)
0
>>>
why would this be? And when is someone going to fix it :P
- Haz
- Next message: Diez B. Roggisch: "Re: oddness in string.find(sub,somestring)"
- Previous message: Franz Steinhäusler: "PyQt on Python 2.4"
- Next in thread: Diez B. Roggisch: "Re: oddness in string.find(sub,somestring)"
- Reply: Diez B. Roggisch: "Re: oddness in string.find(sub,somestring)"
- Reply: Fredrik Lundh: "Re: oddness in string.find(sub,somestring)"
- Reply: Max M: "Re: oddness in string.find(sub,somestring)"
- Reply: Max M: "Re: oddness in string.find(sub,somestring)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]