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 @@ -1641,8 +1641,19 @@ class' :attr:`~object.__dict__`.
1641
1641
Called at the time the owning class *owner * is created. The
1642
1642
descriptor has been assigned to *name *.
1643
1643
1644
- .. versionadded :: 3.6
1644
+ .. note ::
1645
+
1646
+ ``__set_name__ `` is only called implicitly as part of the ``type `` constructor, so
1647
+ it will need to be called explicitly with the appropriate parameters when a
1648
+ descriptor is added to a class after initial creation::
1645
1649
1650
+ descr = custom_descriptor()
1651
+ cls.attr = descr
1652
+ descr.__set_name__(cls, 'attr')
1653
+
1654
+ See :ref: `class-object-creation ` for more details.
1655
+
1656
+ .. versionadded :: 3.6
1646
1657
1647
1658
The attribute :attr: `__objclass__ ` is interpreted by the :mod: `inspect ` module
1648
1659
as specifying the class where this object was defined (setting this
You can’t perform that action at this time.
0 commit comments