Created
October 5, 2015 15:23
-
-
Save iakovgan/7ae27425c3f104c14345 to your computer and use it in GitHub Desktop.
deco_class.py
This file contains 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
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