What is the output of the following code? from functools import wraps def decorator_func(func): @wraps(func) def wrapper(*args, **kwargs): return func(*args, **kwargs) return wrapper @decorator_func def square(x): return x**2 print(square.__name__)

Questions & AnswersCategory: Programming LanguageWhat is the output of the following code? from functools import wraps def decorator_func(func): @wraps(func) def wrapper(*args, **kwargs): return func(*args, **kwargs) return wrapper @decorator_func def square(x): return x**2 print(square.__name__)
Adam asked 2 years ago

What is the output of the following code?

from functools import wraps

def decorator_func(func):

    @wraps(func)

    def wrapper(*args, **kwargs):

        return func(*args, **kwargs)

    return wrapper

@decorator_func

def square(x):

    return x**2

print(square.__name__)

 
a. Error
b. wrapper
c. decorator_func
d. square