]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-134976: document the exception type that can be raised by `s[i]` (GH-134977...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 8 Jun 2025 12:37:55 +0000 (14:37 +0200)
committerGitHub <noreply@github.com>
Sun, 8 Jun 2025 12:37:55 +0000 (14:37 +0200)
gh-134976: document the exception type that can be raised by `s[i]` (GH-134977)
(cherry picked from commit 158e5162bfaa8a49178ce2c3f2455c3e03b60157)

Co-authored-by: Yongzi Li <204532581+Yzi-Li@users.noreply.github.com>
Doc/library/stdtypes.rst

index b279c693a6cc3167a73c64e40eba7d92275698e7..a3c54274597984dd2442ff329dbefc631dfd28ed 100644 (file)
@@ -976,7 +976,7 @@ operations have the same priority as the corresponding numeric operations. [3]_
 | ``s * n`` or             | equivalent to adding *s* to    | (2)(7)   |
 | ``n * s``                | itself *n* times               |          |
 +--------------------------+--------------------------------+----------+
-| ``s[i]``                 | *i*\ th item of *s*, origin 0  | \(3)     |
+| ``s[i]``                 | *i*\ th item of *s*, origin 0  | (3)(9)   |
 +--------------------------+--------------------------------+----------+
 | ``s[i:j]``               | slice of *s* from *i* to *j*   | (3)(4)   |
 +--------------------------+--------------------------------+----------+
@@ -1108,6 +1108,9 @@ Notes:
    without copying any data and with the returned index being relative to
    the start of the sequence rather than the start of the slice.
 
+(9)
+   An :exc:`IndexError` is raised if *i* is outside the sequence range.
+
 
 .. _typesseq-immutable: