New submission from Paul Pinterits <rawi...@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@python
components: Documentation
messages: 303968
nosy: Paul Pinterits, docs@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue31735>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to