Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f13a3cc

Browse filesBrowse files
committed
gh-113212: Document zero-arg super() inside nested functions and generator expressions
1 parent 13c3597 commit f13a3cc
Copy full SHA for f13a3cc

File tree

2 files changed

+8
-1
lines changed
Filter options

2 files changed

+8
-1
lines changed

‎Doc/library/functions.rst

Copy file name to clipboardExpand all lines: Doc/library/functions.rst
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1800,6 +1800,13 @@ are always available. They are listed here in alphabetical order.
18001800
the second argument is a type, ``issubclass(type2, type)`` must be true (this
18011801
is useful for classmethods).
18021802

1803+
When called directly within an ordinary method of a class, both arguments may
1804+
be omitted ("zero-argument :func:`super`"). In this case, *type* will be the
1805+
enclosing class, and *obj* will be the first argument of the immediately
1806+
enclosing function (typically ``self``). (This means that zero-argument
1807+
:func:`super` will not work as expected within a nested function or a generator
1808+
expression, which implicitly creates a nested function.)
1809+
18031810
There are two typical use cases for *super*. In a class hierarchy with
18041811
single inheritance, *super* can be used to refer to parent classes without
18051812
naming them explicitly, thus making the code more maintainable. This use
@@ -1845,7 +1852,6 @@ are always available. They are listed here in alphabetical order.
18451852
:func:`super`, see `guide to using super()
18461853
<https://rhettinger.wordpress.com/2011/05/26/super-considered-super/>`_.
18471854

1848-
18491855
.. _func-tuple:
18501856
.. class:: tuple()
18511857
tuple(iterable)
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve :py:class:`super` error messages.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.