bug in str.startswith() and str.endswith()

Duncan Booth duncan.booth at invalid.invalid
Fri May 27 06:31:44 EDT 2011


Carl Banks <pavlovevidence at gmail.com> wrote:

> The end parameter looks pretty useless for
> .startswith() and is probably only present for consistency with other
> string search methods like .index().

No, the end parameter could be useful if the slice ends up shorter than the 
prefix string:

>>> 'abcd'.startswith('abc', 0, 2)
False

Likewise the start parameter for endswith.

-- 
Duncan Booth http://kupuguy.blogspot.com



More information about the Python-list mailing list