[Tutor] printing variable name and value?
Borgulya Gabor
borgulya@pons.sote.hu
Sun, 28 May 2000 20:35:24 +0200 (CEST)
Hi!
When I am testing my scripts, I often need the following line:
print 'x =',x
But as I like verbose variable names I hate to type them twice.
I wanted to write a small function that works like this:
>>> x=5
>>> print_variable('x')
x = 5
>>>
But I was unable to do it. If I pass the print_variable function the value
of x, like print_variable(x), I can not access the variable name. And if I
pass it the variable name, like above, I can not access the value of the
variable, because I am in a new name space.
Do I need such complicated methods as Traceback?
Gabor