Skip to content

Instantly share code, notes, and snippets.

@marcellmars
Created March 3, 2015 17:44
Show Gist options
  • Save marcellmars/25ada085612863a3de30 to your computer and use it in GitHub Desktop.
Save marcellmars/25ada085612863a3de30 to your computer and use it in GitHub Desktop.
foo decorator
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