mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
gh-113313: Note that slice support is not required for all sequences. (gh-113377)
This commit is contained in:
parent
31d8757b60
commit
6a5b4736e5
1 changed files with 3 additions and 3 deletions
|
|
@ -2808,9 +2808,9 @@ through the object's keys; for sequences, it should iterate through the values.
|
||||||
.. method:: object.__getitem__(self, key)
|
.. method:: object.__getitem__(self, key)
|
||||||
|
|
||||||
Called to implement evaluation of ``self[key]``. For :term:`sequence` types,
|
Called to implement evaluation of ``self[key]``. For :term:`sequence` types,
|
||||||
the accepted keys should be integers and slice objects. Note that the
|
the accepted keys should be integers. Optionally, they may support
|
||||||
special interpretation of negative indexes (if the class wishes to emulate a
|
:class:`slice` objects as well. Negative index support is also optional.
|
||||||
:term:`sequence` type) is up to the :meth:`__getitem__` method. If *key* is
|
If *key* is
|
||||||
of an inappropriate type, :exc:`TypeError` may be raised; if *key* is a value
|
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
|
outside the set of indexes for the sequence (after any special
|
||||||
interpretation of negative values), :exc:`IndexError` should be raised. For
|
interpretation of negative values), :exc:`IndexError` should be raised. For
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue