Message276908
Look at this:
>>> from collections.abc import Sequence
>>> help(Sequence.index)
index(self, value, start=0, stop=None)
S.index(value, [start, [stop]]) -> integer -- return first index of value.
Raises ValueError if the value is not present.
>>> issubclass(range, Sequence)
True
>>> help(range.index)
index(...)
rangeobject.index(value, [start, [stop]]) -> integer -- return index of value.
Raise ValueError if the value is not present.
So far, so good. But:
>>> range(9).index(2, 1, 5)
TypeError: index() takes exactly one argument (3 given)
Of course it's not essential, but the docs shouldn't lie. And if range _is_ a Sequence, then it should have the complete interface of a Sequence. Including start and end arguments for .index: they are optional from the point of call, not from the point of implementation. :-) |
|
Date |
User |
Action |
Args |
2016-09-18 20:50:32 | veky | set | recipients:
+ veky, docs@python |
2016-09-18 20:50:32 | veky | set | messageid: <1474231832.91.0.157673750963.issue28197@psf.upfronthosting.co.za> |
2016-09-18 20:50:32 | veky | link | issue28197 messages |
2016-09-18 20:50:32 | veky | create | |
|