[Python-checkins] bpo-23674: Clarify ambiguities in super() docs (GH-15564) (GH-15586)
Raymond Hettinger
webhook-mailer at python.org
Thu Aug 29 04:03:05 EDT 2019
https://github.com/python/cpython/commit/43b7ed77a8224c378b436ad3385733454198be41
commit: 43b7ed77a8224c378b436ad3385733454198be41
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Raymond Hettinger <rhettinger at users.noreply.github.com>
date: 2019-08-29T01:02:58-07:00
summary:
bpo-23674: Clarify ambiguities in super() docs (GH-15564) (GH-15586)
(cherry picked from commit cd81f0500fe98c7f4cddb06530fffabd14f036b8)
Co-authored-by: Raymond Hettinger <rhettinger at users.noreply.github.com>
files:
M Doc/library/functions.rst
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index c225f3dee921..c748b086d8ac 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -1587,10 +1587,17 @@ are always available. They are listed here in alphabetical order.
Return a proxy object that delegates method calls to a parent or sibling
class of *type*. This is useful for accessing inherited methods that have
- been overridden in a class. The search order is same as that used by
- :func:`getattr` except that the *type* itself is skipped.
+ been overridden in a class.
- The :attr:`~class.__mro__` attribute of the *type* lists the method
+ The *object-or-type* determines the :term:`method resolution order`
+ to be searched. The search starts from the class right after the
+ *type*.
+
+ For example, if :attr:`~class.__mro__` of *object-or-type* is
+ ``D -> B -> C -> A -> object`` and the value of *type* is ``B``,
+ then :func:`super` searches ``C -> A -> object``.
+
+ The :attr:`~class.__mro__` attribute of the *object-or-type* lists the method
resolution search order used by both :func:`getattr` and :func:`super`. The
attribute is dynamic and can change whenever the inheritance hierarchy is
updated.
More information about the Python-checkins
mailing list