I want to get a dictionary from a function that has the function arguments as keys and the default values as values.
I used inspect.getfullargspec() to get a list of the argument and a list of the default values. Then I tried to use dict(zip()) to create a dictionary of those lists. This works, but only if every arguments has a default value. If one has no default, everything gets mixed up (as expected).
How can I for example if a argument has no default, add a None as value.
Or any other ideas?
Here's the code:
def fn(name, age=18):
pass
spec = getfullargspec(fn)
args = spec.args
defaults = spec.defaults
zipped = dict(zip(args, defaults))