In Python function decorators are again functions that are first class citizens, which creates the expectation of assigning and passing around flexibly. In below example
def auth_token_not_expired(function):
@auth_token_right
def wrapper(req):
# Some validations
return function(req)
return wrapper
Now I tried assigning this decorator function to another variable as alias
login_required = auth_token_not_expired
Upon inspecting the assignment happens successfully however when I invoke it using @login_required
syntax it causes NameError
Exception Type: NameError
Exception Value:
name 'login_required' is not defined
How do we register this login_required
variable too as decorator?