Title: Descriptors HowTo doesn't mention __set_name__
Type: Stage: resolved
Components: Documentation Versions: Python 3.10, Python 3.9
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: MarSoft, docs@python, rhettinger, wim.glenn
Priority: normal Keywords:

Created on 2018-08-13 12:36 by MarSoft, last changed 2020-11-24 00:44 by rhettinger. This issue is now closed.

Messages (6)
msg323479 - (view) Author: Semyon (MarSoft) Date: 2018-08-13 12:36
There is a great HowTo document for descriptors
But it doesn't even mention the __set_name__ method which was added in py3. And it lists the descriptor protocol without that method as if it is the full protocol. The only way to know about that method is to go to the link for any other method and then you'll see that there is a __set_name__.
I think the guide sholud be updated to include at least information about existence of __set_name__.
msg323494 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2018-08-13 22:12
Thanks. I'm already working on this.
msg376943 - (view) Author: wim glenn (wim.glenn) * Date: 2020-09-15 15:55
Hi Raymond, any update on this?
msg376960 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2020-09-15 22:34
I have a draft PR but haven't checked it in yet.  Will do so shortly :-)
msg379413 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2020-10-23 08:40
msg381703 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2020-11-24 00:44
For the record, __set_name__ isn't specific to descriptors.  It can be used with any class:

    >>> class A:
            def __set_name__(*args):
    >>> class B:
            x = A()
            y = A()
    (<__main__.A object at 0x7febfe01ac40>, <class '__main__.B'>, 'x')
    (<__main__.A object at 0x7febfe01a5e0>, <class '__main__.B'>, 'y')
Date User Action Args
2020-11-24 00:44:11rhettingersetmessages: + msg381703
2020-10-23 19:57:20rhettingersetstatus: open -> closed
stage: resolved
resolution: fixed
versions: + Python 3.9, Python 3.10, - Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8
2020-10-23 08:40:03rhettingersetmessages: + msg379413
2020-09-15 22:34:52rhettingersetmessages: + msg376960
2020-09-15 15:55:27wim.glennsetnosy: + wim.glenn
messages: + msg376943
2019-10-25 04:36:52rhettingerlinkissue38587 superseder
2018-08-13 22:12:06rhettingersetassignee: docs@python -> rhettinger

messages: + msg323494
nosy: + rhettinger
2018-08-13 12:36:26MarSoftcreate