Message243167
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. |
|
Date |
User |
Action |
Args |
2015-05-14 10:20:00 | pitrou | set | recipients:
+ pitrou, yselivanov |
2015-05-14 10:20:00 | pitrou | set | messageid: <1431598800.08.0.914868739501.issue24190@psf.upfronthosting.co.za> |
2015-05-14 10:20:00 | pitrou | link | issue24190 messages |
2015-05-14 10:19:59 | pitrou | create | |
|