Skip to content

Instantly share code, notes, and snippets.

@ARezaK
Created October 27, 2014 01:41
Show Gist options
  • Save ARezaK/5a332b7f693be337fe68 to your computer and use it in GitHub Desktop.
Save ARezaK/5a332b7f693be337fe68 to your computer and use it in GitHub Desktop.
Print variables by inspecting them
import inspect
def my_print(var):
callers_local_vars = inspect.currentframe().f_back.f_locals.items()
print str([var_name for var_name, var_val in callers_local_vars if var_val is var]) + " is " + str(var)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment