A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/1999-June/095460.html below:

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

[Python-Dev] RE: [Python-Dev] String methods... finallyTim 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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4