[issue34394] Descriptors HowTo doesn't mention __set_name__
New submission from Semyon <simeon+bpo@maryasin.name>: There is a great HowTo document for descriptors https://github.com/python/cpython/blob/master/Doc/howto/descriptor.rst 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__. ---------- assignee: docs@python components: Documentation messages: 323479 nosy: MarSoft, docs@python priority: normal severity: normal status: open title: Descriptors HowTo doesn't mention __set_name__ versions: Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34394> _______________________________________
Raymond Hettinger <raymond.hettinger@gmail.com> added the comment: Thanks. I'm already working on this. ---------- assignee: docs@python -> rhettinger nosy: +rhettinger _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34394> _______________________________________
wim glenn <wim.glenn@gmail.com> added the comment: Hi Raymond, any update on this? ---------- nosy: +wim.glenn _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34394> _______________________________________
Raymond Hettinger <raymond.hettinger@gmail.com> added the comment: I have a draft PR but haven't checked it in yet. Will do so shortly :-) ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34394> _______________________________________
Raymond Hettinger <raymond.hettinger@gmail.com> added the comment: See https://github.com/python/cpython/pull/22906 ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34394> _______________________________________
Change by Raymond Hettinger <raymond.hettinger@gmail.com>: ---------- resolution: -> fixed stage: -> resolved status: open -> closed versions: +Python 3.10, Python 3.9 -Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34394> _______________________________________
Raymond Hettinger <raymond.hettinger@gmail.com> added the comment: For the record, __set_name__ isn't specific to descriptors. It can be used with any class: >>> class A: def __set_name__(*args): print(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') ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34394> _______________________________________
participants (3)
-
Raymond Hettinger -
Semyon -
wim glenn