Created
September 2, 2011 21:08
-
-
Save kunev/1189922 to your computer and use it in GitHub Desktop.
verbose function call snooping
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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