Skip to content

Instantly share code, notes, and snippets.

@jrosco
Created June 13, 2015 06:50
Show Gist options
  • Select an option

  • Save jrosco/4c5e70c6853eb1e936dd to your computer and use it in GitHub Desktop.

Select an option

Save jrosco/4c5e70c6853eb1e936dd to your computer and use it in GitHub Desktop.
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