Help me in understanding the flow of control in this

users={“harjot”:“password”}

def login_required(func):
def wrapper(username,password,*args,**kwargs):
if username in users and users[username]==password:
func(*args,**kwargs)
else:
print(“fuck off bondua”)
return wrapper
@login_required
def add(a,b):
print(a+b)

add(“harjot”,“password”,2,3)

Hey,

When you put a decorator @ with a function like @login_requried it will first execute this function.
and in the login_requried you have checked whether username and password match with the existing ones,. if yes then you actually call the original function with parameters in forms args and kwargs.

First add(“harjot”,“password”,2,3) line will be executed then the program flow will go to
def login_required(func):
def wrapper(username,password,*args,**kwargs):
if username in users and users[username]==password:
Here the crediential will match and then it will call you function func(*args,**kwargs) which is actually your add function…