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

2011-05-27 Thread Duncan Booth
Carl Banks pavlovevide...@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:

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

2011-05-27 Thread Mel
Terry Reedy wrote: To me, that says pretty clearly that start and end have to be 'positions', ie, ints or other index types. So I would say that the error message is a bug. I see so reason why one would want to use None rather that 0 for start or None rather than nothing for end. If you're

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

2011-05-27 Thread Roy Smith
In article mailman.2144.1306471679.9059.python-l...@python.org, Stefan Behnel stefan...@behnel.de 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

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

2011-05-27 Thread Ethan Furman
Ethan Furman wrote: Any reason this is not a bug? Looks like someone else beat me to filing: http://bugs.python.org/issue11828 Looks like they fixed it as well. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

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

2011-05-26 Thread MRAB
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

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

2011-05-26 Thread Carl Banks
On Thursday, May 26, 2011 4:27:22 PM UTC-7, MRAB wrote: 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

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

2011-05-26 Thread Mel
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__

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

2011-05-26 Thread Roy Smith
In article mailman.2136.1306451668.9059.python-l...@python.org, Ethan Furman et...@stoneleaf.us 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

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

2011-05-26 Thread Terry Reedy
On 5/26/2011 7:27 PM, 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

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

2011-05-26 Thread Steven D'Aprano
On Thu, 26 May 2011 23:00:32 -0400, Terry Reedy wrote: [...] To me, that says pretty clearly that start and end have to be 'positions', ie, ints or other index types. So I would say that the error message is a bug. I see so reason why one would want to use None rather that 0 for start or

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

2011-05-26 Thread Stefan Behnel
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, inmodule TypeError: slice indices must be integers or None or have an __index__ method