Message284336
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 |
|
Date |
User |
Action |
Args |
2016-12-30 16:38:21 | ncoghlan | set | recipients:
+ ncoghlan, xiang.zhang, lanfon72 |
2016-12-30 16:38:21 | ncoghlan | set | messageid: <1483115901.84.0.58573560206.issue29114@psf.upfronthosting.co.za> |
2016-12-30 16:38:21 | ncoghlan | link | issue29114 messages |
2016-12-30 16:38:21 | ncoghlan | create | |
|