Skip to content

Instantly share code, notes, and snippets.

@rahulkmr
Created May 13, 2012 12:00
Show Gist options
  • Select an option

  • Save rahulkmr/2688055 to your computer and use it in GitHub Desktop.

Select an option

Save rahulkmr/2688055 to your computer and use it in GitHub Desktop.
import 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 = "test"
b = "test"
show(a)
c = 10
d = 10
show(c)
# Output
a='test'
b='test'
c=10
d=10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment