Can I pass a variable to the decorator in python?

is that the A function uses the decorator, and the variable var inside the A function is passed to the decorator, and then it is checked and so on, okay?

Jun.30,2021

def decorator(func):
    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        if len(args) == 4:
            return func(*args, **kwargs)
        else:
            raise AssertionError("args must be exact!")
    return wrapper
Menu