Last active
August 29, 2015 14:07
-
-
Save rasmusto/6f4a2a254c2eca92cd11 to your computer and use it in GitHub Desktop.
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
def decorator(fn): | |
def f(): | |
return "dec" + fn() | |
f.decorated=True | |
f.original_func = fn | |
return f | |
def decorator_override(fn): | |
def f(): | |
if fn.decorated: | |
return "ovr" + fn.original_func() | |
else: | |
return "fresh" + fn() | |
f.decorated=True | |
f.original_func=fn | |
return f | |
@decorator_override | |
@decorator | |
def hello_ovr(): | |
return "hello" | |
hello_ovr() | |
# 'ovrhello' | |
@decorator | |
def hello(): | |
return "hello" | |
hello() | |
# 'dechello' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment