For logging purpose I tried to automatically catch the arguments passed to a function inside this function and convert them to a dict of arg : value
.
I tried the inspect.signature()
module but it only provides with the default input of the function and not the argument passed to it
import inspect
def my_add_func(a, b ,c=3):
sig = inspect.signature(my_add_func)
print("my_add_func args : {0}".format(sig))
return a + b + c
if __name__ == '__main__':
my_add_func(10, 2, 3)
Outputs:
(a, b, c=3)
Whereas I would like to have:
{a: 10, b: 2, c:3}
How can I do that?