[New-bugs-announce] [issue31735] Documentation incorrectly states how descriptors are invoked

Paul Pinterits report at bugs.python.org
Mon Oct 9 11:04:44 EDT 2017


New submission from Paul Pinterits <rawing7 at gmail.com>:

The [descriptor howto](https://docs.python.org/3/howto/descriptor.html#invoking-descriptors) states:

"For example, obj.d looks up d in the dictionary of obj. If d defines the method __get__(), then d.__get__(obj) is invoked [...]"

This is not true - the descriptor obtained from obj's dictionary is never invoked. If it was, the following two snippets would produce output:


class Class:
    pass

obj = Class()
obj.__dict__['d'] = property(lambda: print('called'))

_ = obj.d  # nothing is printed.


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

_ = Obj.d  # nothing is printed.

----------
assignee: docs at python
components: Documentation
messages: 303968
nosy: Paul Pinterits, docs at python
priority: normal
severity: normal
status: open
title: Documentation incorrectly states how descriptors are invoked
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8

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


More information about the New-bugs-announce mailing list