This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients lanfon72, ncoghlan, xiang.zhang
Date 2016-12-30.16:38:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1483115901.84.0.58573560206.issue29114@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2016-12-30 16:38:21ncoghlansetrecipients: + ncoghlan, xiang.zhang, lanfon72
2016-12-30 16:38:21ncoghlansetmessageid: <1483115901.84.0.58573560206.issue29114@psf.upfronthosting.co.za>
2016-12-30 16:38:21ncoghlanlinkissue29114 messages
2016-12-30 16:38:21ncoghlancreate