[docs] [issue31735] Documentation incorrectly states how descriptors are invoked

Paul Pinterits report at bugs.python.org
Mon Oct 9 12:55:22 EDT 2017


Paul Pinterits <rawing7 at gmail.com> added the comment:

If we take this class:

class Obj:
    @property
    def d(self):
        print('called')

And we access Obj.d:

_ = Obj.d

According to the docs, the following should happen:

# obj.d looks up d in the dictionary of obj
d = Obj.__dict__['d']

# If d defines the method __get__(),
if hasattr(d, '__get__'):

    # then d.__get__(obj) is invoked
    d.__get__(Obj)

We know this doesn't happen because nothing is printed to stdout.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31735>
_______________________________________


More information about the docs mailing list