Skip to content

Instantly share code, notes, and snippets.

@neara
Last active December 28, 2015 02:59
Show Gist options
  • Save neara/7432429 to your computer and use it in GitHub Desktop.
Save neara/7432429 to your computer and use it in GitHub Desktop.
Wrapper Func for extracting function args and kwargs
class MyClassWrapper(object):
def __init__(self, f, myarg):
self.myarg = myarg
self.args = ''
self.kwargs = ''
self.func = f
def __call__(self, *args, **kwargs):
self.args = args
self.kwargs = kwargs
r = self.func(*args, **kwargs)
print self.args, self.kwargs
return True
@MyClassWrapper('foobar')
def foo():
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment