From 0603a79354bac76aedfde38a14c7253cee1e304d Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Thu, 21 Dec 2023 14:00:21 -0600 Subject: [PATCH 1/2] gh-113313: Note that slice support is not required for all sequences. --- Doc/reference/datamodel.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index c774d75433420e..01618b30ce8127 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, it 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 From 9a972cccc9bcc42a7984a08bcb4efbb8f35bb8fd Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Thu, 21 Dec 2023 14:43:36 -0600 Subject: [PATCH 2/2] Grammar edit --- Doc/reference/datamodel.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index 01618b30ce8127..b3af5c6298d02d 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -2808,7 +2808,7 @@ 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. Optionally, it may support + 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