Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 518d8da

Browse files
committed
Issue 1163367: Clarify super() docs. Also, fix-up the markup and XXX comment.
1 parent 40c509d commit 518d8da

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

Doc/library/functions.rst

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,18 +1037,16 @@ are always available. They are listed here in alphabetical order.
10371037

10381038
.. function:: super([type[, object-or-type]])
10391039

1040-
.. XXX updated as per http://www.artima.com/weblogs/viewpost.jsp?thread=208549 but needs checking
1041-
1042-
Return a "super" object that acts like the superclass of *type*.
1040+
Return a *super* object that acts as a proxy to superclasses of *type*.
10431041

10441042
If the second argument is omitted the super object returned is unbound. If
10451043
the second argument is an object, ``isinstance(obj, type)`` must be true. If
10461044
the second argument is a type, ``issubclass(type2, type)`` must be true.
10471045
Calling :func:`super` without arguments is equivalent to ``super(this_class,
10481046
first_arg)``.
10491047

1050-
There are two typical use cases for "super". In a class hierarchy with
1051-
single inheritance, "super" can be used to refer to parent classes without
1048+
There are two typical use cases for :func:`super`. In a class hierarchy with
1049+
single inheritance, :func:`super` can be used to refer to parent classes without
10521050
naming them explicitly, thus making the code more maintainable. This use
10531051
closely parallels the use of "super" in other programming languages.
10541052

@@ -1072,9 +1070,12 @@ are always available. They are listed here in alphabetical order.
10721070
It does so by implementing its own :meth:`__getattribute__` method for searching
10731071
parent classes in a predictable order that supports cooperative multiple inheritance.
10741072
Accordingly, :func:`super` is undefined for implicit lookups using statements or
1075-
operators such as ``super()[name]``. Also, :func:`super` is not
1076-
limited to use inside methods: under the hood it searches the stack
1077-
frame for the class (``__class__``) and the first argument.
1073+
operators such as ``super()[name]``.
1074+
1075+
Also note that :func:`super` is not limited to use inside methods. The
1076+
two argument specifies the arguments exactly and makes the appropriate
1077+
references. The zero argument form automatically searches the stack frame
1078+
for the class (``__class__``) and the first argument.
10781079

10791080

10801081
.. function:: tuple([iterable])

0 commit comments

Comments
 (0)