0

Suppose that I call a function f with a statement like the following:

f(a, b, x)

Inside the function f, I would like to be able to determine the names of the variables that the caller passed. (I realize that this is bad programming practice). Is there a way of doing this?

Phillip M. Feldman
  • 468
  • 1
  • 7
  • 17

1 Answers1

0

You can try to find your variables in vars() locals() and globals(). You should search for the id of your variable in those dictionaries but there are some problems when you are in a sub-function. Then you could still give environment parameters like eval does for example.

ersteller
  • 71
  • 4