]> granicus.if.org Git - python/commitdiff
Issue #1446619: Account for negative slice direction in description
authorMartin Panter <vadmium+py@gmail.com>
Sat, 24 Dec 2016 08:25:15 +0000 (08:25 +0000)
committerMartin Panter <vadmium+py@gmail.com>
Sat, 24 Dec 2016 08:25:15 +0000 (08:25 +0000)
Based on suggestion from Fumihiro Bessho.

Doc/library/stdtypes.rst

index 1e19fd464c53a49e004ec62f8f6233818ef6b079..4174f79a897ba1a8814ed061bafb0e350fa33cf4 100644 (file)
@@ -942,8 +942,10 @@ Notes:
    The slice of *s* from *i* to *j* with step *k* is defined as the sequence of
    items with index  ``x = i + n*k`` such that ``0 <= n < (j-i)/k``.  In other words,
    the indices are ``i``, ``i+k``, ``i+2*k``, ``i+3*k`` and so on, stopping when
-   *j* is reached (but never including *j*).  If *i* or *j* is greater than
-   ``len(s)``, use ``len(s)``.  If *i* or *j* are omitted or ``None``, they become
+   *j* is reached (but never including *j*).  When *k* is positive,
+   *i* and *j* are reduced to ``len(s)`` if they are greater.
+   When *k* is negative, *i* and *j* are reduced to ``len(s) - 1`` if
+   they are greater.  If *i* or *j* are omitted or ``None``, they become
    "end" values (which end depends on the sign of *k*).  Note, *k* cannot be zero.
    If *k* is ``None``, it is treated like ``1``.