Skip to content

Commit ca8ca6b

Browse files
[3.14] gh-145591: Move slicing note to __getitem__ (GH-145606) (GH-145760)
(cherry picked from commit 2114da9) Co-authored-by: Ali Towaiji <145403626+Towaiji@users.noreply.github.com>
1 parent 6080c86 commit ca8ca6b

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

Doc/reference/datamodel.rst

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3242,21 +3242,6 @@ through the object's keys; for sequences, it should iterate through the values.
32423242
.. versionadded:: 3.4
32433243

32443244

3245-
.. index:: pair: object; slice
3246-
3247-
.. note::
3248-
3249-
Slicing is done exclusively with the following three methods. A call like ::
3250-
3251-
a[1:2] = b
3252-
3253-
is translated to ::
3254-
3255-
a[slice(1, 2, None)] = b
3256-
3257-
and so forth. Missing slice items are always filled in with ``None``.
3258-
3259-
32603245
.. method:: object.__getitem__(self, subscript)
32613246

32623247
Called to implement *subscription*, that is, ``self[subscript]``.
@@ -3279,6 +3264,22 @@ through the object's keys; for sequences, it should iterate through the values.
32793264
should raise an :exc:`LookupError` or one of its subclasses
32803265
(:exc:`IndexError` for sequences; :exc:`KeyError` for mappings).
32813266

3267+
.. index:: pair: object; slice
3268+
3269+
.. note::
3270+
3271+
Slicing is handled by :meth:`!__getitem__`, :meth:`~object.__setitem__`,
3272+
and :meth:`~object.__delitem__`.
3273+
A call like ::
3274+
3275+
a[1:2] = b
3276+
3277+
is translated to ::
3278+
3279+
a[slice(1, 2, None)] = b
3280+
3281+
and so forth. Missing slice items are always filled in with ``None``.
3282+
32823283
.. note::
32833284

32843285
The sequence iteration protocol (used, for example, in :keyword:`for`

0 commit comments

Comments
 (0)