Skip to content

Instantly share code, notes, and snippets.

@aloni636
Created March 12, 2024 12:53
Show Gist options
  • Save aloni636/665cb808da60b04d1f78e69e77caf9eb to your computer and use it in GitHub Desktop.
Save aloni636/665cb808da60b04d1f78e69e77caf9eb to your computer and use it in GitHub Desktop.
General Python Utilities
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