Created
September 13, 2017 10:13
-
-
Save stevemolloy/b561961c4c857bc88008df8fa27a5a59 to your computer and use it in GitHub Desktop.
Conditional decorator in Python (only slightly modified from a stackoverflow answer)
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 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