Find out the name of a variable passed as an argument

Andreas Huesgen andreas.huesgen at arcor.de
Wed Oct 4 21:19:24 CEST 2006


Hello everybody,

is there a way to receive the name of an object passed to a function 
from within the function.

something like

def foo(param):
	print theNameOfTheVariablePassedToParam

var1 = "hello"
var2 = "world"

 >>> foo(var1)
var1

 >>> foo(var2)
var2

thanks in advance,

greets

Andreas Huesgen




More information about the Python-list mailing list