[Python-checkins] Move __missing__ after __delitem__ in Data model. (GH-10923)
Miss Islington (bot)
webhook-mailer at python.org
Wed Dec 5 15:13:37 EST 2018
https://github.com/python/cpython/commit/9b3d6a1f9772e810afaa0dca106bd0e4d5f4be9f
commit: 9b3d6a1f9772e810afaa0dca106bd0e4d5f4be9f
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2018年12月05日T12:13:34-08:00
summary:
Move __missing__ after __delitem__ in Data model. (GH-10923)
(cherry picked from commit 1ce853f37783575e2b3aaa159ddcebc8660830ef)
Co-authored-by: Andre Delfino <adelfino at gmail.com>
files:
M Doc/reference/datamodel.rst
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index abf06357e7f9..143376bc5ce0 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -2045,6 +2045,8 @@ through the container; for mappings, :meth:`__iter__` should be the same as
.. versionadded:: 3.4
+.. index:: object: slice
+
.. note::
Slicing is done exclusively with the following three methods. A call like ::
@@ -2060,8 +2062,6 @@ through the container; for mappings, :meth:`__iter__` should be the same as
.. method:: object.__getitem__(self, key)
- .. index:: object: slice
-
Called to implement evaluation of ``self[key]``. For 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 sequence
@@ -2077,12 +2077,6 @@ through the container; for mappings, :meth:`__iter__` should be the same as
indexes to allow proper detection of the end of the sequence.
-.. method:: object.__missing__(self, key)
-
- Called by :class:`dict`\ .\ :meth:`__getitem__` to implement ``self[key]`` for dict subclasses
- when key is not in the dictionary.
-
-
.. method:: object.__setitem__(self, key, value)
Called to implement assignment to ``self[key]``. Same note as for
@@ -2101,6 +2095,12 @@ through the container; for mappings, :meth:`__iter__` should be the same as
values as for the :meth:`__getitem__` method.
+.. method:: object.__missing__(self, key)
+
+ Called by :class:`dict`\ .\ :meth:`__getitem__` to implement ``self[key]`` for dict subclasses
+ when key is not in the dictionary.
+
+
.. method:: object.__iter__(self)
This method is called when an iterator is required for a container. This method
More information about the Python-checkins
mailing list