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

Henk-Jaap Wagenaar report at bugs.python.org
Tue Oct 10 04:46:31 EDT 2017


Henk-Jaap Wagenaar <wagenaarhenkjaap at gmail.com> added the comment:

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

Try running Obj().d, you will get output.

Obj.d does not work because it is on a *class*, and so it runs, per the docs:

'Obj.__dict__['d'].__get__(None, Obj)'

whereas you consider running it on an instance to get:

b = Obj()
b.d
# equivalent to
type(b).__dict__['d'].__get__(b, type(b))

and you will get output twice.

[Note, on python2 you will get an error, I think this is because your class does not inherit from object.]

----------

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


More information about the docs mailing list