Skip to content

Instantly share code, notes, and snippets.

@stevemolloy
Created September 13, 2017 10:13
Show Gist options
  • Save stevemolloy/b561961c4c857bc88008df8fa27a5a59 to your computer and use it in GitHub Desktop.
Save stevemolloy/b561961c4c857bc88008df8fa27a5a59 to your computer and use it in GitHub Desktop.
Conditional decorator in Python (only slightly modified from a stackoverflow answer)
def conditional_decorator(input_decorator, condition):
def output_decorator(func):
if not condition:
return func
return input_decorator(func)
return output_decorator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment