[issue41427] howto/descriptor.rst unnecessarily mentions method.__class__

Raymond Hettinger report at bugs.python.org
Tue Jul 28 19:48:37 EDT 2020


Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:

The origin of the error was an incorrect update from Python 2 semantics where the class was exposed as an attribute:

Python 2.7.17 (v2.7.17:c2f86d86e6, Oct 19 2019, 16:24:34) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license()" for more information.
>>> class A:
	def f(self, x):
		return x
	
>>> a = A()
>>> bm = a.f
>>> bm.im_class
<class __main__.A at 0x1002daf30>
>>> bm.im_self
<__main__.A instance at 0x103a204b0>
>>> bm.im_func
<function f at 0x1004ed950>

----------

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


More information about the Python-bugs-list mailing list