[issue29114] __class__ not exists in the method which bounded by types.MethodType.
Nick Coghlan
report at bugs.python.org
Fri Dec 30 11:38:21 EST 2016
Nick Coghlan added the comment:
Sorry, I wasn't at all clear about that part - the above techniques should work with explicitly created types.MethodType instances as well.
That is, this should work the same as in my earlier examples (although I don't have that interpreter session around to test it any more):
>>> b = B()
>>> b.fn = types.MethodType(make_B_method(), b)
>>> b.fn() # Emulated super()
<class '__main__.A'>
If you were to build on top of what I wrote above (i.e. setting "B.fn = make_B_method()"), that explicit bound method creation would be akin to doing:
>>> b = B()
>>> b.fn = b.fn # Cache the bound method on the instance
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29114>
_______________________________________
More information about the Python-bugs-list
mailing list