Looks like you are looking for locals :
>>> def foo(a, b): ... return locals() ... >>> foo(1, 2) {'b': 2, 'a': 1} >>> def foo(a, b, c, d, e): ... return locals() ... >>> foo(1, 2, 3, 4, 5) {'c': 3, 'b': 2, 'a': 1, 'e': 5, 'd': 4} >>>
Note that this will return a dictionary of all names in the foo scope:
>>> def foo(a, b): ... x = 3 ... return locals() ... >>> foo(1, 2) {'b': 2, 'a': 1, 'x': 3} >>>
This should not be a problem if your functions are similar to the data in your question. If so, you can use inspect.getfullargspec and a dictionary understanding to filter locals() :
>>> def foo(a, b): ... import inspect
iCodez
source share