Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #6348 > unrolled thread
| Started by | Ethan Furman <ethan@stoneleaf.us> |
|---|---|
| First post | 2011-05-26 16:27 -0700 |
| Last post | 2011-05-27 09:48 -0400 |
| Articles | 5 — 4 participants |
Back to article view | Back to comp.lang.python
bug in str.startswith() and str.endswith() Ethan Furman <ethan@stoneleaf.us> - 2011-05-26 16:27 -0700
Re: bug in str.startswith() and str.endswith() Mel <mwilson@the-wire.com> - 2011-05-26 21:07 -0400
Re: bug in str.startswith() and str.endswith() Roy Smith <roy@panix.com> - 2011-05-26 21:13 -0400
Re: bug in str.startswith() and str.endswith() Stefan Behnel <stefan_ml@behnel.de> - 2011-05-27 06:47 +0200
Re: bug in str.startswith() and str.endswith() Roy Smith <roy@panix.com> - 2011-05-27 09:48 -0400
| From | Ethan Furman <ethan@stoneleaf.us> |
|---|---|
| Date | 2011-05-26 16:27 -0700 |
| Subject | bug in str.startswith() and str.endswith() |
| Message-ID | <mailman.2136.1306451668.9059.python-list@python.org> |
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~
[toc] | [next] | [standalone]
| From | Mel <mwilson@the-wire.com> |
|---|---|
| Date | 2011-05-26 21:07 -0400 |
| Message-ID | <irmtg2$19i$1@speranza.aioe.org> |
| In reply to | #6348 |
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.
[toc] | [prev] | [next] | [standalone]
| From | Roy Smith <roy@panix.com> |
|---|---|
| Date | 2011-05-26 21:13 -0400 |
| Message-ID | <roy-E793ED.21131126052011@news.panix.com> |
| In reply to | #6348 |
In article <mailman.2136.1306451668.9059.python-list@python.org>,
Ethan Furman <ethan@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 must be integers or None or have an __index__
> method
[...]
> Any reason this is not a bug?
+1 for it being a bug.
[toc] | [prev] | [next] | [standalone]
| From | Stefan Behnel <stefan_ml@behnel.de> |
|---|---|
| Date | 2011-05-27 06:47 +0200 |
| Message-ID | <mailman.2144.1306471679.9059.python-list@python.org> |
| In reply to | #6357 |
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
[toc] | [prev] | [next] | [standalone]
| From | Roy Smith <roy@panix.com> |
|---|---|
| Date | 2011-05-27 09:48 -0400 |
| Message-ID | <roy-F4537A.09483927052011@news.panix.com> |
| In reply to | #6370 |
In article <mailman.2144.1306471679.9059.python-list@python.org>,
Stefan Behnel <stefan_ml@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 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 :-)
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web