8000 bpo-23674: Clarify ambiguities in super() docs (GH-15564) (GH-15586) · python/cpython@43b7ed7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 43b7ed7

Browse files
bpo-23674: Clarify ambiguities in super() docs (GH-15564) (GH-15586)
(cherry picked from commit cd81f05) Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
1 parent d1d42bf commit 43b7ed7

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

Doc/library/functions.rst

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,10 +1587,17 @@ are always available. They are listed here in alphabetical order.
15871587

15881588
Return a proxy object that delegates method calls to a parent or sibling
15891589
class of *type*. This is useful for accessing inherited methods that have
1590-
been overridden in a class. The search order is same as that used by
1591-
:func:`getattr` except that the *type* itself is skipped.
1590+
been overridden in a class.
15921591

1593-
The :attr:`~class.__mro__` attribute of the *type* lists the method
1592+
The *object-or-type* determines the :term:`method resolution order`
1593+
to be searched. The search starts from the class right after the
1594+
*type*.
1595+
1596+
For example, if :attr:`~class.__mro__` of *object-or-type* is
1597+
``D -> B -> C -> A -> object`` and the value of *type* is ``B``,
1598+
then :func:`super` searches ``C -> A -> object``.
1599+
1600+
The :attr:`~class.__mro__` attribute of the *object-or-type* lists the method
15941601
resolution search order used by both :func:`getattr` and :func:`super`. The
15951602
attribute is dynamic and can change whenever the inheritance hierarchy is
15961603
updated.

0 commit comments

Comments
 (0)
0