getting name of passed reference

Martin P. Hellwig martin.hellwig at dcuktec.org
Tue Dec 29 14:43:05 EST 2009


Joel Davis wrote:
> I'm just curious if anyone knows of a way to get the variable name of
> a reference passed to the function.
> 
> Put another way, in the example:
> 
>   def MyFunc ( varPassed ):
>      print varPassed;
> 
>   MyFunc(nwVar)
> 
> how would I get the string "nwVar" from inside of "MyFunc"? is it
> possible?

Would it be acceptable to require keyword arguments when calling the 
function?

 >>> def test(**kwargs):
	print(kwargs)

 >>> test(x=1)
{'x': 1}
 >>>


-- 
MPH
http://blog.dcuktec.com
'If consumed, best digested with added seasoning to own preference.'



More information about the Python-list mailing list