getting the name of a variable

Sandy Norton sandskyfly at hotmail.com
Thu Dec 6 13:47:37 CET 2001


When I'm debugging I'm always sticking stuff like "print 'x:', x" in my code.
So is there a handy function that will print a variable name and value such that: 

>>> def print_var_name_and_value(var):
            "prints variable name : value"
            <implemention>

>>> variable = 'me var'
>>> print_var_name_and_value(variable)
variable : me var


Any responses, pointers, hints would be much appreciated.

thanx.

Sandy



More information about the Python-list mailing list