From: Helge Stenström on 17 Mar 2010 09:20 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(1).f_locals[name] > > def f(): > fred = 42 > mary = "christmas" > print_var("fred") > print_var("mary") > > f() > > -- > Greg
First
|
Prev
|
Pages: 1 2 Prev: "Breaking" the __main__ script Next: Is it possible to use re2 from Python? |