3 ms·
yup, thanks for the heads up, it worked for me. I realized that most of that was unnecessary, this is what I was talking about: import gc, sys def show(
by notaddicted 14y ago
yup, thanks for the heads up, it worked for me. I realized that most of that was unnecessary, this is what I was talking about:
import gc, sys
def show(*args):
for obj in args:
frame = sys._getframe(1)
for k,v in frame.f_locals.iteritems():
if v is obj:
print "%s=%r" % (k,v)
a, b, c, d, e, = False, 1, [1,2,3], {'x':2 }, map
show(a, b, c, d, e)
outputs:
a=False
b=1
c=[1, 2, 3]
d={'x': 2}
e=<built-in function map>
[ http://codepad.org/4JogU069 http://codepad.org/4JogU069 ] [ edit: slight cleanup]
- irahul 14y agoNot so useful when you have shared pool. a = 10 b = 10 show(a) Or a = 'test' b = 'test' show(a)