summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2017-12-12 10:58:26 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2017-12-12 10:58:26 (GMT)
commit78cd00b799be36a35c9f5cc99ce3bcef31112a5f (patch)
tree2beb0539bc3a1d5c83d55b16052c38136618b8b6
parentce5a3cd9b15c9379753aefabd696bff11495cbbb (diff)
downloadcpython-78cd00b799be36a35c9f5cc99ce3bcef31112a5f.zip
cpython-78cd00b799be36a35c9f5cc99ce3bcef31112a5f.tar.gz
cpython-78cd00b799be36a35c9f5cc99ce3bcef31112a5f.tar.bz2
bpo-31942: Document optional support of start and stop attributes in Sequence.index method (GH-4277) (#4811)
(cherry picked from commit 5ce0a2a100909104836f53a2c8823006ec46f8ad)
-rw-r--r--Doc/library/stdtypes.rst6
-rw-r--r--Lib/_collections_abc.py3
2 files changed, 6 insertions, 3 deletions
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index 75e97b9..196a4c0 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -973,9 +973,9 @@ Notes:
(8)
``index`` raises :exc:`ValueError` when *x* is not found in *s*.
- When supported, the additional arguments to the index method allow
- efficient searching of subsections of the sequence. Passing the extra
- arguments is roughly equivalent to using ``s[i:j].index(x)``, only
+ Not all implementations support passing the additional arguments *i* and *j*.
+ These arguments allow efficient searching of subsections of the sequence. Passing
+ the extra arguments is roughly equivalent to using ``s[i:j].index(x)``, only
without copying any data and with the returned index being relative to
the start of the sequence rather than the start of the slice.
diff --git a/Lib/_collections_abc.py b/Lib/_collections_abc.py
index 005d884..aafd430 100644
--- a/Lib/_collections_abc.py
+++ b/Lib/_collections_abc.py
@@ -899,6 +899,9 @@ class Sequence(Reversible, Collection):
def 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.
+
+ Supporting start and stop arguments is optional, but
+ recommended.
'''
if start is not None and start < 0:
start = max(len(self) + start, 0)