Skip to content

Instantly share code, notes, and snippets.

@iakovgan
Created October 5, 2015 15:23
Show Gist options
  • Save iakovgan/7ae27425c3f104c14345 to your computer and use it in GitHub Desktop.
Save iakovgan/7ae27425c3f104c14345 to your computer and use it in GitHub Desktop.
deco_class.py
import wrapt
@wrapt.decorator
def pass_through(wrapped, instance, args, kwargs):
print instance.attr
return wrapped(*args, **kwargs)
class Class(object):
attr = "Hi"
@pass_through
@classmethod
def function_cm(cls, arg1, arg2):
pass
Class.function_cm(1, 2)
c = Class() # print's 'Hi'
c.attr = 'hi again'
c.function_cm(3, 4) # print's just 'Hi'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment