FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.5] bpo-30354: Update data model documentation for super() (GH-1561) by csabella · Pull Request #1869 · python/cpython · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .rst  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
12 changes: 6 additions & 6 deletions Doc/reference/datamodel.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1088,9 +1088,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
Expand All @@ -1114,7 +1114,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),
Expand Down Expand Up @@ -1538,8 +1538,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__)``.

Expand Down

Back | FazBrowse Home | New Git URL