diff options
author | csabella <chekat2@gmail.com> | 2017-05-30 20:48:22 (GMT) |
---|---|---|
committer | Mariatta <Mariatta@users.noreply.github.com> | 2017-05-30 20:48:22 (GMT) |
commit | ad13d54646d189cea8e6f7a9bc4a87e20df33ac4 (patch) | |
tree | 206e5003c8863f12dbf0c9ba4d08364164bb4c85 /Doc/reference | |
parent | 00b381b9a7b6b15350d1dcf7c688bf808cbf0ebb (diff) | |
download | cpython-ad13d54646d189cea8e6f7a9bc4a87e20df33ac4.zip cpython-ad13d54646d189cea8e6f7a9bc4a87e20df33ac4.tar.gz cpython-ad13d54646d189cea8e6f7a9bc4a87e20df33ac4.tar.bz2 |
bpo-30354: Update data model documentation for super() (GH-1561) (GH-1868)
The data model section of the language reference was written well
before the zero-argument form of super() was added.
To avoid giving the impression that they're doing something
unusual, this updates the description of `__new__` and `__init__`
to use the zero-argument form.
Patch by Cheryl Sabella.
(cherry picked from commit 12b1c180986fc744331b8f30d3d2f49a0fdb43dd)
Diffstat (limited to 'Doc/reference')
-rw-r--r-- | Doc/reference/datamodel.rst | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index 35925a0..0e0a9e2 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -1119,9 +1119,9 @@ Basic customization (usually an instance of *cls*). Typical implementations create a new instance of the class by invoking the - superclass's :meth:`__new__` method using ``super(currentclass, - cls).__new__(cls[, ...])`` with appropriate arguments and then modifying the - newly-created instance as necessary before returning it. + superclass's :meth:`__new__` method using ``super().__new__(cls[, ...])`` + with appropriate arguments and then modifying the newly-created instance + as necessary before returning it. If :meth:`__new__` returns an instance of *cls*, then the new instance's :meth:`__init__` method will be invoked like ``__init__(self[, ...])``, where @@ -1145,7 +1145,7 @@ Basic customization class constructor expression. If a base class has an :meth:`__init__` method, the derived class's :meth:`__init__` method, if any, must explicitly call it to ensure proper initialization of the base class part of the - instance; for example: ``BaseClass.__init__(self, [args...])``. + instance; for example: ``super().__init__([args...])``. Because :meth:`__new__` and :meth:`__init__` work together in constructing objects (:meth:`__new__` to create it, and :meth:`__init__` to customize it), @@ -1578,8 +1578,8 @@ Class Binding ``A.__dict__['x'].__get__(None, A)``. Super Binding - If ``a`` is an instance of :class:`super`, then the binding ``super(B, - obj).m()`` searches ``obj.__class__.__mro__`` for the base class ``A`` + If ``a`` is an instance of :class:`super`, then the binding ``super(B, obj).m()`` + searches ``obj.__class__.__mro__`` for the base class ``A`` immediately preceding ``B`` and then invokes the descriptor with the call: ``A.__dict__['m'].__get__(obj, obj.__class__)``. |