Python, Python Programming, Programming, Coding, Artificial Intelligence.
require_auth(func): def wrapper(*args, **kwargs): if not authenticated(): raise Exception("Not authenticated") return func(*args, **kwargs) return wrapper @require_auth def protected_function(): print("Protected function") def authenticated(): return False try: protected_function() except Exception