]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-134976: document the exception type that can be raised by `s[i]` (#134977)
authorYongzi Li <204532581+Yzi-Li@users.noreply.github.com>
Sun, 8 Jun 2025 12:28:55 +0000 (20:28 +0800)
committerGitHub <noreply@github.com>
Sun, 8 Jun 2025 12:28:55 +0000 (14:28 +0200)
Doc/library/stdtypes.rst

index f0b4b09ff10dcec54f5ca56de6a726716013f9a5..b75e5ceecf874e8c6efa484d5d1f66180c131190 100644 (file)
@@ -1018,7 +1018,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)   |
 +--------------------------+--------------------------------+----------+
@@ -1150,6 +1150,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: