[Python-Dev] RE: [Python-Dev] String methods... finally

Tim Peters tim_one at email.msn.com
Tue Jun 15 17:33:40 CEST 1999


>> A bug:
>>
>> >>> 'ab'.endswith('b',0,1) # right
>> 0
>> >>> 'ab'.endswith('ab',0,1) # wrong
>> 1
>> >>> 'ab'.endswith('ab',0,0) # wrong
>> 1
>> >>>

[Ka-Ping]
> I assumed you meant that the extra arguments should be slices
> on the string being searched, i.e.
>
>     specimen.startswith(text, start, end)
>
> is equivalent to
>
>     specimen[start:end].startswith(text)
>
> without the overhead of slicing the specimen?  Or did i understand
> you correctly?

Yes, and e.g. 'ab'[0:1] == 'a', which does not end with 'ab'.  So these are
inconsistent today, and the second is a bug:

>>> 'ab'[0:1].endswith('ab')
0
>>> 'ab'.endswith('ab', 0, 1)
1
>>>

Or did I misunderstand you <wink>?






More information about the Python-Dev mailing list