PyDocs

Nav

Python Runtime Services

getcallargs

inspect

function · Added in 3.2 (source) Deprecated 3.5
  • getcallargs(func, /, *args, **kwds)
Deprecated since 3.5. Use Signature.bind() and Signature.bind_partial() instead.
Get the mapping of arguments to values.

A dict is returned, with keys the function argument names (including the
names of the * and ** arguments, if any), and values the respective bound
values from 'positional' and 'named'.
1 Example
>>> from inspect import getcallargs
>>> def f(a, b=1, *pos, **named):
...     pass
...
>>> getcallargs(f, 1, 2, 3) == {'a': 1, 'named': {}, 'b': 2, 'pos': (3,)}
True
>>> getcallargs(f, a=2, x=4) == {'a': 2, 'named': {'x': 4}, 'b': 1, 'pos': ()}
True
>>> getcallargs(f)
Traceback (most recent call last):
...
TypeError: f() missing 1 required positional argument: 'a'
from the Python docs
See Also
No see-alsos for inspect/getcallargs
0 Notes
No notes for getcallargs