Question 9
Back to Exercise
How does the wrapper still know which function to call after the decorator has returned?
- A func is a global variable
- B Python passes func again on every call
- C It is a closure: it remembers func from the enclosing decorator's scope Correct
- D It looks func up by name in the module
Correct Answer: Option C
The enclosing scope's variables live on as long as the inner function needs them.
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!