Author pitrou
Recipients pitrou, yselivanov
Date 2015-05-14.10:19:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1431598800.08.0.914868739501.issue24190@psf.upfronthosting.co.za>
In-reply-to
Content
The recipe to inject default values in a BoundArguments instance is given in the doc, but it's not trivial. Furthermore, it's actually incomplete: it doesn't handle any star-arguments, e.g.:

>>> sig = inspect.signature(f)
>>> ba = sig.bind(2, d=4)
>>> for param in sig.parameters.values():
...     if (param.name not in ba.arguments
...             and param.default is not param.empty):
...         ba.arguments[param.name] = param.default
... 
>>> ba.arguments
OrderedDict([('a', 2), ('d', 4), ('b', 5)])

ba['c'] would ideally contain the empty tuple.
History
Date User Action Args
2015-05-14 10:20:00pitrousetrecipients: + pitrou, yselivanov
2015-05-14 10:20:00pitrousetmessageid: <1431598800.08.0.914868739501.issue24190@psf.upfronthosting.co.za>
2015-05-14 10:20:00pitroulinkissue24190 messages
2015-05-14 10:19:59pitroucreate