File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -1655,8 +1655,19 @@ class' :attr:`~object.__dict__`.
1655
1655
Called at the time the owning class *owner * is created. The
1656
1656
descriptor has been assigned to *name *.
1657
1657
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::
1659
1663
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
1660
1671
1661
1672
The attribute :attr: `__objclass__ ` is interpreted by the :mod: `inspect ` module
1662
1673
as specifying the class where this object was defined (setting this
You can’t perform that action at this time.
0 commit comments