[issue34394] Descriptors HowTo doesn't mention __set_name__

Raymond Hettinger report at bugs.python.org
Mon Nov 23 19:44:11 EST 2020


Raymond Hettinger <raymond.hettinger at 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 at bugs.python.org>
<https://bugs.python.org/issue34394>
_______________________________________


More information about the Python-bugs-list mailing list