Skip to content

Instantly share code, notes, and snippets.

@dario61081
Created February 26, 2024 14:18
Show Gist options
  • Save dario61081/5d3b2cf59e7fda23d106ef5403e11830 to your computer and use it in GitHub Desktop.
Save dario61081/5d3b2cf59e7fda23d106ef5403e11830 to your computer and use it in GitHub Desktop.
decoradores varios
from functools import wraps
def require_permission(func):
@wraps(func)
def eval_permission(permission: str, *args, **kwargs):
return func(*args, **kwargs)
return eval_permission
def singleton(cls):
"""
Convert to singleton
"""
instance = [None]
def wrapper(*arg, **kwargs):
if instance[0] is None:
instance[0] = cls(*arg, **kwargs)
return instance[0]
return wrapper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment