Created
June 13, 2015 06:50
-
-
Save jrosco/4c5e70c6853eb1e936dd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class LogWrappedFunction(object): | |
| def __init__(self, function): | |
| self.function = function | |
| def logAndCall(self, *arguments, **namedArguments): | |
| print "Calling %s with arguments %s and named arguments %s" %\ | |
| (self.function.func_name, arguments, namedArguments) | |
| self.function.__call__(*arguments, **namedArguments) | |
| def logwrap(function): | |
| return LogWrappedFunction(function).logAndCall | |
| @logwrap | |
| def doSomething(spam, eggs, foo, bar): | |
| print "Doing something totally awesome with %s and %s." % (spam, eggs) | |
| doSomething("beans","rice", foo="wiggity", bar="wack") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment