Created
March 12, 2024 12:53
-
-
Save aloni636/665cb808da60b04d1f78e69e77caf9eb to your computer and use it in GitHub Desktop.
General Python Utilities
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
from typing import Callable | |
def conditional_decorator(condition: bool, decorator: Callable, *args, **kwargs): | |
if condition: | |
if len(args) == 0 and len(kwargs) == 0: | |
return decorator | |
return decorator(*args, **kwargs) | |
return lambda x: x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment