Skip to content

Instantly share code, notes, and snippets.

@kunev
Created September 2, 2011 21:08
Show Gist options
  • Save kunev/1189922 to your computer and use it in GitHub Desktop.
Save kunev/1189922 to your computer and use it in GitHub Desktop.
verbose function call snooping
import inspect
def print_args(func):
argspec = inspect.getargspec(func)
expected_arguments, expected_varargs = argspec.args, argspec.varargs
def rslt(*args, **kwargs):
print 'Calling {0}\n\tArguments: {1}\n\tKeyword arguments: {2}'.format(func.__name__, args, kwargs)
return_val = func(*args, **kwargs)
print '\n\tReturned value: {0}'.format(return_val)
return return_val
return rslt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment