LearnFrenzy
Sign in Take a free test

Decorators · Decorators MCQ · Question 9

Closures and decorators Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links