]> granicus.if.org Git - python/commitdiff
bpo-31942: Document optional support of start and stop attributes in Sequence.index...
authorNitish Chandra <nitishchandrachinta@gmail.com>
Tue, 12 Dec 2017 10:22:30 +0000 (15:52 +0530)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 12 Dec 2017 10:22:30 +0000 (11:22 +0100)
Doc/library/stdtypes.rst
Lib/_collections_abc.py

index 0bcafd33b20b85977192bb7df74c4e5f96ab6ea9..de2fb27c2d78cb8d1bb958784776e5ee7baf7149 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 e89e84bc08112738cf57fecb8ddd71c6eede700c..a5c7bfcda1d755ac673cb9555be778817ccffec1 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)