[New-bugs-announce] [issue41427] howto/descriptor.rst unnecessarily mentions method.__class__
Yonatan Goldschmidt
report at bugs.python.org
Tue Jul 28 16:47:00 EDT 2020
New submission from Yonatan Goldschmidt <yon.goldschmidt at gmail.com>:
In Doc/howto/descriptor.rst:
# Internally, the bound method stores the underlying function,
# the bound instance, and the class of the bound instance.
>>> d.f.__func__
<function D.f at 0x1012e5ae8>
>>> d.f.__self__
<__main__.D object at 0x1012e1f98>
>>> d.f.__class__
<class 'method'>
The bound method (PyMethodObject) does not store "the class of the bound instance" - it only stores the "function" and "self".
d.f.__class__ is the class of the "method" type itself, not the class of d.f's instance (D from d = D())
I think this mention should be removed from the documentation?
----------
assignee: docs at python
components: Documentation
messages: 374526
nosy: Yonatan Goldschmidt, docs at python
priority: normal
severity: normal
status: open
title: howto/descriptor.rst unnecessarily mentions method.__class__
type: enhancement
versions: Python 3.10
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41427>
_______________________________________
More information about the New-bugs-announce
mailing list