Skip to content

Commit

Permalink
bpo-38524: clarify example a bit and improve formatting (pythonGH-17406)
Browse files Browse the repository at this point in the history
  • Loading branch information
taleinat authored Nov 28, 2019
1 parent d9aa216 commit 02519f7
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Doc/reference/datamodel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit 02519f7

Please sign in to comment.