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 <[email protected]>
<http://bugs.python.org/issue29114>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com