Skip to content

Instantly share code, notes, and snippets.

@phill-tornroth
Created June 5, 2012 20:10
Show Gist options
  • Save phill-tornroth/2877507 to your computer and use it in GitHub Desktop.
Save phill-tornroth/2877507 to your computer and use it in GitHub Desktop.
Playing with class decorators
>>> class my_dec(object):
... def __init__(self, f):
... self.f = f
...
>>> class my_dec(object):
... def __init__(self, f):
... self.f = f
... def __call__(self, *args):
... return self.f(*args)
...
>>> @my_dec
... def my_func(x,y):
... return y-x
...
>>> isinstance(my_func, my_dec)
True
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment