Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > bug in str.startswith() and str.endswith()

Reply
Thread Tools

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

 
 
Ethan Furman
Guest
Posts: n/a
 
      05-26-2011
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?

~Ethan~
 
Reply With Quote
 
 
 
 
Mel
Guest
Posts: n/a
 
      05-27-2011
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?


It's a wart at the very least. The same thing happened in Python2 with
range and xrange; there seemed no way to explicitly pass "default"
arguments.

Mel.

 
Reply With Quote
 
 
 
 
Roy Smith
Guest
Posts: n/a
 
      05-27-2011
In article <mailman.2136.1306451668.9059.python->,
Ethan Furman <> wrote:

> --> '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

[...]
> Any reason this is not a bug?


+1 for it being a bug.
 
Reply With Quote
 
Stefan Behnel
Guest
Posts: n/a
 
      05-27-2011
Roy Smith, 27.05.2011 03:13:
> Ethan Furman wrote:
>
>> --> '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

> [...]
>> Any reason this is not a bug?

>
> +1 for it being a bug.


Meaning that the right thing to do at this point is to file a bug report.

Stefan

 
Reply With Quote
 
Roy Smith
Guest
Posts: n/a
 
      05-27-2011
In article <mailman.2144.1306471679.9059.python->,
Stefan Behnel <> wrote:

> Roy Smith, 27.05.2011 03:13:
> > Ethan Furman wrote:
> >
> >> --> '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

> > [...]
> >> Any reason this is not a bug?

> >
> > +1 for it being a bug.

>
> Meaning that the right thing to do at this point is to file a bug report.


And now we just need to figure out if it's a bug in the code or the
documentation
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
*bug* *bug* *bug* David Raleigh Arnold Firefox 12 04-02-2007 03:13 AM
ASP.NET Login control bug or SQL 2005 bug? RedEye ASP .Net 2 12-13-2005 10:57 AM
Re: BUG? OR NOT A BUG? John ASP .Net 2 09-21-2005 10:31 AM
rdoc bug (and rdoc bug tracker site is down) Brian Schröder Ruby 5 09-18-2004 02:08 PM
how to report bug to g++ ? got a bug and fixed up source code DarkSpy C++ 4 06-27-2003 09:05 AM



Advertisments