chicken_turtle_util.inspect¶
Similar to inspect module. Contains only function call inspect utilities
call_args |
Get function call arguments as a single dict |
-
chicken_turtle_util.inspect.
call_args
(f, args=(), kwargs={})[source]¶ Get function call arguments as a single dict
Parameters: f : function
The function of the function call
args : iterable(any)
Arguments of the function call
kwargs : {str => any}
Keyword arguments of the function call
Returns: {arg_name :: str => arg_value :: any}
Dict of arguments including args, kwargs and any missing optional arguments of f.
Examples
>>> def f(a=1, *my_args, k=None, **kwargs): ... pass ... >>> call_args(f) {'a': 1, 'k': None, '*args': ()} >>> call_args(f, [3]) {'a': 3, 'k': None, '*args': ()} >>> call_args(f, [3], dict(k='some')) {'a': 3, 'k': 'some', '*args': ()} >>> call_args(f, [3, 4]) {'a': 3, 'k': None, '*args': (4,)} >>> call_args(f, dict(other='some')) {'a': 1, 'k': None, 'other': 'some', '*args': ()} >>> def g(): ... pass ... >>> call_args(g) {}