Skip to content

Instantly share code, notes, and snippets.

@pyrtsa
Created March 2, 2010 14:35
Show Gist options
  • Save pyrtsa/319546 to your computer and use it in GitHub Desktop.
Save pyrtsa/319546 to your computer and use it in GitHub Desktop.
def inspect(*names)
def inspect(*names):
"""Print values of the given expressions. Use at your own risk.
Usage examples:
>>> x,y,something = 1,'y',3.14159
>>> inspect('x')
x = 1
>>> inspect(*'x y something'.split())
x = 1
y = 'y'
something = 3.1415899999999999
"""
m = max(len(n) for n in names)
for name in names:
print('{0:>{m}} = {1}'.format(name, repr(eval(name)), m=m))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment