Question 2
Back to Exercise
What is the output of the following Python program?
from functools import wraps
def d1(f):
def wrapper(*a): return f(*a)
return wrapper
def d2(f):
@wraps(f)
def wrapper(*a): return f(*a)
return wrapper
@d1
def alpha(): pass
@d2
def beta(): pass
print(alpha.__name__, beta.__name__)
- A alpha beta
- B wrapper wrapper
- C wrapper beta Correct
- D alpha wrapper
Correct Answer: Option C
Without wraps the decorated name reports the wrapper's metadata.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!