bpo-38255: super() can search attributes as well as methods (GH-16368) (GH-16392)

Improvement suggested by Géry Ogam.
(cherry picked from commit 15ccc4fac0)

Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2019-09-25 08:24:24 -07:00 committed by Raymond Hettinger
parent d3666945d7
commit 3b5e924114
1 changed files with 4 additions and 0 deletions

View File

@ -1532,6 +1532,10 @@ are always available. They are listed here in alphabetical order.
super().method(arg) # This does the same thing as:
# super(C, self).method(arg)
In addition to method lookups, :func:`super` also works for attribute
lookups. One possible use case for this is calling :term:`descriptor`\s
in a parent or sibling class.
Note that :func:`super` is implemented as part of the binding process for
explicit dotted attribute lookups such as ``super().__getitem__(name)``.
It does so by implementing its own :meth:`__getattribute__` method for searching