Skip to content

Commit 78cd00b

Browse files
miss-islingtonvstinner
authored andcommitted
bpo-31942: Document optional support of start and stop attributes in Sequence.index method (GH-4277) (#4811)
(cherry picked from commit 5ce0a2a)
1 parent ce5a3cd commit 78cd00b

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Doc/library/stdtypes.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -973,9 +973,9 @@ Notes:
973973

974974
(8)
975975
``index`` raises :exc:`ValueError` when *x* is not found in *s*.
976-
When supported, the additional arguments to the index method allow
977-
efficient searching of subsections of the sequence. Passing the extra
978-
arguments is roughly equivalent to using ``s[i:j].index(x)``, only
976+
Not all implementations support passing the additional arguments *i* and *j*.
977+
These arguments allow efficient searching of subsections of the sequence. Passing
978+
the extra arguments is roughly equivalent to using ``s[i:j].index(x)``, only
979979
without copying any data and with the returned index being relative to
980980
the start of the sequence rather than the start of the slice.
981981

Lib/_collections_abc.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,9 @@ def __reversed__(self):
899899
def index(self, value, start=0, stop=None):
900900
'''S.index(value, [start, [stop]]) -> integer -- return first index of value.
901901
Raises ValueError if the value is not present.
902+
903+
Supporting start and stop arguments is optional, but
904+
recommended.
902905
'''
903906
if start is not None and start < 0:
904907
start = max(len(self) + start, 0)

0 commit comments

Comments
 (0)