1

I would like to retrieve the variable name passed as an argument to a function.

Here is an example of the result I am looking for:

def my_func(a, b):   
    return a + b

>>> foo, bar = 1, 2
>>> get_arg_var_names(my_func(foo, bar))
foo
bar

Please note that I am not looking retrieve a and b.

Tanguy
  • 3,124
  • 4
  • 21
  • 29
  • 2
    What if the function gets called like `my_func(1,2)`? What if it gets called like `my_func(input(), input())`? What if it gets called like `t = (23, 42); my_func(*t)`? – Kevin Nov 06 '17 at 16:15
  • What is the purpose of using the names of the variables which were passed in? Aren't the variable names declared inside the function good enough to access the values? – Code-Apprentice Nov 06 '17 at 16:22

0 Answers0