rfind bug ?
James Mills
prologic at shortcircuit.net.au
Wed Apr 21 05:06:12 EDT 2010
On Wed, Apr 21, 2010 at 6:51 PM, Stef Mientki <stef.mientki at gmail.com> wrote:
>
> With the following code, I would expect a result of 5 !!
>
>>>> a= 'word1 word2 word3'
>>>> a.rfind(' ',7)
> 11
>
> Is this a bug ?
Python's documentation states:
| rfind(...)
| S.rfind(sub [,start [,end]]) -> int
|
| Return the highest index in S where substring sub is found,
| such that sub is contained within s[start:end]. Optional
| arguments start and end are interpreted as in slice notation.
|
| Return -1 on failure.
"Return the highest index in S"
I haven't looked at python's source code for the
str object, but perhaps this is exactly what it's
algorithm does!
cheers
James
More information about the Python-list
mailing list