]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-31942: Document optional support of start and stop attributes in Sequence.index...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 12 Dec 2017 10:58:26 +0000 (02:58 -0800)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 12 Dec 2017 10:58:26 +0000 (11:58 +0100)
(cherry picked from commit 5ce0a2a100909104836f53a2c8823006ec46f8ad)

Doc/library/stdtypes.rst
Lib/_collections_abc.py

index 75e97b9d8f5bbecfcabc258537f022ac69869ac5..196a4c0005677163cc8cdc8ebc0da2b5010ff75b 100644 (file)
@@ -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.
 
index 005d884572465f261f9f6186a4e5817f8754df92..aafd43046a02a5a17175d16167caae2cb62a1cda 100644 (file)
@@ -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)