Re: Function that knows its argument's variable name

2010-03-17 Thread Helge Stenström
Thank you to all who answered. Inspection is apparently possible, but too complex for me. Greg's solution does what I want, inserting "" is no problem. /Helge > Not exactly, but you can come close with a little hackery. > > import sys > > def print_var(name): >    print name, "=", sys._getframe(

Function that knows its argument's variable name

2010-03-14 Thread Helge Stenström
I want to write function that prints a value of a variable, for debugging. Like: with myVariable = "parrot" otherVariable = "dead" probe(myVariable) probe(otherVariable) instead of the longer print "myVariable = ", myVariable print "otherVariable = ", otherVariable Is that even possible? Th