Skip to content

Commit 7444a5a

Browse files
bpo-38255: super() can search attributes as well as methods (GH-16368) (GH-16391)
Improvement suggested by Géry Ogam. (cherry picked from commit 15ccc4f) Co-authored-by: Raymond Hettinger <[email protected]>
1 parent e4be8c9 commit 7444a5a

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
@@ -1635,6 +1635,10 @@ are always available. They are listed here in alphabetical order.
16351635
super().method(arg) # This does the same thing as:
16361636
# super(C, self).method(arg)
16371637

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

0 commit comments

Comments
 (0)