getting the name of a variable

Michael Hudson mwh at python.net
Thu Dec 6 16:30:39 CET 2001


sandskyfly at hotmail.com (Sandy Norton) writes:

> 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

Not really.  Hit google groups for more info.  Some highlights:

a gross implementation attempt by me:

http://groups.google.com/groups?selm=m38zytnexz.fsf%40atrus.jesus.cam.ac.uk

a nice explanation of why this not really possible by /F:

http://groups.google.com/groups?selm=3a03261b_1%40corp.newsfeeds.com

Cheers,
M.

-- 
  : exploding like a turd
  Never had that happen to me, I have to admit.  They do that
  often in your world?              -- Eric The Read & Dave Brown, asr



More information about the Python-list mailing list