bpo-38524: clarify example a bit and improve formatting (GH-17406)

(cherry picked from commit 02519f75d1)

Co-authored-by: Tal Einat <taleinat+github@gmail.com>
This commit is contained in:
Miss Islington (bot) 2019-11-27 21:29:02 -08:00 committed by GitHub
parent d21b8e82dd
commit c0db88f6ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 5 deletions

View File

@ -1657,13 +1657,16 @@ class' :attr:`~object.__dict__`.
.. note::
``__set_name__`` is only called implicitly as part of the ``type`` constructor, so
it will need to be called explicitly with the appropriate parameters when a
descriptor is added to a class after initial creation::
:meth:`__set_name__` is only called implicitly as part of the
:class:`type` constructor, so it will need to be called explicitly with
the appropriate parameters when a descriptor is added to a class after
initial creation::
class A:
pass
descr = custom_descriptor()
cls.attr = descr
descr.__set_name__(cls, 'attr')
A.attr = descr
descr.__set_name__(A, 'attr')
See :ref:`class-object-creation` for more details.