diff options
author | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2023-12-21 21:54:59 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-21 21:54:59 (GMT) |
commit | 6a5b4736e548fc5827c3bcf1a14193f77e1a989d (patch) | |
tree | d6e2305cdcd57d351505fffe10815e56699ec96b /Doc/reference | |
parent | 31d8757b6070010b0fb92a989b1812ecf303059f (diff) | |
download | cpython-6a5b4736e548fc5827c3bcf1a14193f77e1a989d.zip cpython-6a5b4736e548fc5827c3bcf1a14193f77e1a989d.tar.gz cpython-6a5b4736e548fc5827c3bcf1a14193f77e1a989d.tar.bz2 |
gh-113313: Note that slice support is not required for all sequences. (gh-113377)
Diffstat (limited to 'Doc/reference')
-rw-r--r-- | Doc/reference/datamodel.rst | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index c774d75..b3af5c6 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -2808,9 +2808,9 @@ through the object's keys; for sequences, it should iterate through the values. .. method:: object.__getitem__(self, key) Called to implement evaluation of ``self[key]``. For :term:`sequence` types, - the accepted keys should be integers and slice objects. Note that the - special interpretation of negative indexes (if the class wishes to emulate a - :term:`sequence` type) is up to the :meth:`__getitem__` method. If *key* is + the accepted keys should be integers. Optionally, they may support + :class:`slice` objects as well. Negative index support is also optional. + If *key* is of an inappropriate type, :exc:`TypeError` may be raised; if *key* is a value outside the set of indexes for the sequence (after any special interpretation of negative values), :exc:`IndexError` should be raised. For |