Created
March 3, 2015 17:44
-
-
Save marcellmars/25ada085612863a3de30 to your computer and use it in GitHub Desktop.
foo decorator
This file contains hidden or 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 foo(foo_return): | |
def foo_decorator(func): | |
def func_wrapper(name): | |
if foo_return: | |
return foo_return | |
else: | |
return func(name) | |
return func_wrapper | |
return foo_decorator | |
### use: | |
### @foo(None) for passing the decorated function do its job | |
### @foo("foobar") for returning `return "foobar"` instead of decorated function doing its job |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment