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

Skip to content

Commit cd81f05

Browse files
authored
bpo-23674: Clarify ambiguities in super() docs (#15564)
1 parent 122376d commit cd81f05

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
@@ -1589,10 +1589,17 @@ are always available. They are listed here in alphabetical order.
15891589

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

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

0 commit comments

Comments
 (0)
0