]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38255: super() can search attributes as well as methods (GH-16368) (GH-16392)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 25 Sep 2019 15:24:24 +0000 (08:24 -0700)
committerRaymond Hettinger <rhettinger@users.noreply.github.com>
Wed, 25 Sep 2019 15:24:24 +0000 (08:24 -0700)
Improvement suggested by Géry Ogam.
(cherry picked from commit 15ccc4fac09b866d61b069c6c136aabfe4bac09c)

Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
Doc/library/functions.rst

index 313dbffdcde93ab3daeacc57b25118c759ac06d5..06ba323ca30c6c3ad2fd14eb3e7b5bb37c51fbe8 100644 (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