[New-bugs-announce] [issue24190] BoundArguments facility to inject defaults
Antoine Pitrou
report at bugs.python.org
Thu May 14 12:20:00 CEST 2015
New submission from Antoine Pitrou:
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.
----------
components: Library (Lib)
messages: 243167
nosy: pitrou, yselivanov
priority: normal
severity: normal
status: open
title: BoundArguments facility to inject defaults
type: enhancement
versions: Python 3.5
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24190>
_______________________________________
More information about the New-bugs-announce
mailing list