Skip to content

Commit 15ccc4f

Browse files
authored
bpo-38255: super() can search attributes as well as methods (GH-16368)
Improvement suggested by Géry Ogam.
1 parent 00508a7 commit 15ccc4f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Doc/library/functions.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,6 +1637,10 @@ are always available. They are listed here in alphabetical order.
16371637
super().method(arg) # This does the same thing as:
16381638
# super(C, self).method(arg)
16391639

1640+
In addition to method lookups, :func:`super` also works for attribute
1641+
lookups. One possible use case for this is calling :term:`descriptor`\s
1642+
in a parent or sibling class.
1643+
16401644
Note that :func:`super` is implemented as part of the binding process for
16411645
explicit dotted attribute lookups such as ``super().__getitem__(name)``.
16421646
It does so by implementing its own :meth:`__getattribute__` method for searching

0 commit comments

Comments
 (0)