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 berker.peksag, brett.cannon, larry, matrixise, ncoghlan, nedbat, python-dev, r.david.murray, untitaker, veky, yselivanov
Date 2016-12-01.13:20:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1480598428.31.0.916500207974.issue20438@psf.upfronthosting.co.za>
In-reply-to
Content
Noting for the record, as the general way of querying an unbound method for the name of the first parameter and adding it to the bound arguments:

    def add_instance_arg(callable, bound_args):
        try:
            self = callable.__self__
            func = callable.__func__
        except AttributeError:
            return # Not a bound method
        unbound_sig = inspect.signature(func)
        for name in unbound_sig.parameters:
            bound_args.arguments[name] = self
            break

>>> method = C().method
>>> sig = inspect.signature(method)
>>> sig
<Signature (arg)>
>>> args = sig.bind(1)
>>> args
<BoundArguments (arg=1)>
>>> add_instance_arg(method, args)
>>> args
<BoundArguments (arg=1, self=<__main__.C object at 0x7f07ab719668>)>
History
Date User Action Args
2016-12-01 13:20:28ncoghlansetrecipients: + ncoghlan, brett.cannon, larry, nedbat, r.david.murray, python-dev, berker.peksag, yselivanov, matrixise, veky, untitaker
2016-12-01 13:20:28ncoghlansetmessageid: <1480598428.31.0.916500207974.issue20438@psf.upfronthosting.co.za>
2016-12-01 13:20:28ncoghlanlinkissue20438 messages
2016-12-01 13:20:28ncoghlancreate