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

MRAB python at mrabarnett.plus.com
Thu May 26 19:27:22 EDT 2011


On 27/05/2011 00:27, Ethan Furman wrote:
> I've tried this in 2.5 - 3.2:
>
> --> 'this is a test'.startswith('this')
> True
> --> 'this is a test'.startswith('this', None, None)
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: slice indices must be integers or None or have an __index__
> method
>
> The 3.2 docs say this:
>
> str.startswith(prefix[, start[, end]])
> Return True if string starts with the prefix, otherwise return False.
> prefix can also be a tuple of prefixes to look for. With optional start,
> test string beginning at that position. With optional end, stop
> comparing string at that position
>
> str.endswith(suffix[, start[, end]])
> Return True if the string ends with the specified suffix, otherwise
> return False. suffix can also be a tuple of suffixes to look for. With
> optional start, test beginning at that position. With optional end, stop
> comparing at that position.
>
> Any reason this is not a bug?
>
Let's see: 'start' and 'end' are optional, but aren't keyword
arguments, and can't be None...

I'd say bug.



More information about the Python-list mailing list