Getting external name of passed variable

David Hirschfield davidh at
Tue Jun 20 20:44:31 CEST 2006

I'm not sure this is possible, but it sure would help me if I could do it.

Can a function learn the name of the variable that the caller used to 
pass it a value? For example:

def test(x):
   print x

val = 100

Is it possible for function "test()" to find out that the variable it is 
passed, "x", was called "val" by the caller?
Some kind of stack inspection?

Any help greatly appreciated,

mediocre nebula.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list