On 12/28/2009 3:54 PM Joel Davis said...
I'm just curious if anyone knows of a way to get the variable name of
a reference passed to the function.

For curiosity, sure -- but it's real weak...

Put another way, in the example:

   def MyFunc ( varPassed ):
      print varPassed;

   MyFunc(nwVar)

how would I get the string "nwVar" from inside of "MyFunc"?

Here are some ways of doing this:
http://www.python-forum.org/pythonforum/viewtopic.php?f=14&t=12659

is it possible?

Yes -- but only for a limited set of situations.  Consider the following:

MyFunc(3)

a=[1,2,3,4]
MyFunc(a[2])

b=a
MyFunc(b[2])

def newval(): return 3
MyFunc(newval())

MyFunc(range(3)[-1])

Emile

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to