File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1655,8 +1655,19 @@ class' :attr:`~object.__dict__`.
16551655 Called at the time the owning class *owner * is created. The
16561656 descriptor has been assigned to *name *.
16571657
1658- .. versionadded :: 3.6
1658+ .. note ::
1659+
1660+ ``__set_name__ `` is only called implicitly as part of the ``type `` constructor, so
1661+ it will need to be called explicitly with the appropriate parameters when a
1662+ descriptor is added to a class after initial creation::
16591663
1664+ descr = custom_descriptor()
1665+ cls.attr = descr
1666+ descr.__set_name__(cls, 'attr')
1667+
1668+ See :ref: `class-object-creation ` for more details.
1669+
1670+ .. versionadded :: 3.6
16601671
16611672The attribute :attr: `__objclass__ ` is interpreted by the :mod: `inspect ` module
16621673as specifying the class where this object was defined (setting this
You can’t perform that action at this time.
0 commit comments