getting the name of a variable

Michael Hudson mwh at
Thu Dec 6 10:30:39 EST 2001

sandskyfly at (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:

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


  : 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