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-27 Thread Roy Smith
In article , 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 "", line 1, in > >> TypeError: sl

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

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

2011-05-27 Thread Duncan Booth
Carl Banks 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',

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 "", line 1, in TypeError: slice indices must be integers or None or have an __index__ method [...]

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 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 "", line 1, in 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 , Ethan Furman wrote: > --> 'this is a test'.startswith('this') > True > --> 'this is a test'.startswith('this', None, None) > Traceback (most recent call last): >File "", line 1, in > TypeError: slice indices must be integers or None or have an __index__ > method [...] > Any re

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 "", line 1, in > TypeError: slice indices must be integers or None or have an __index__ > me

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 "", l

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 "", line 1, in TypeError: slice indices must be integers or None or have an __index__ m

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

2011-05-26 Thread Ethan Furman
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 "", line 1, in TypeError: slice indices must be integers or None or have an __index__ method The 3.2 docs say this: str.sta