C.W.K.
Stream
Quiz · 3 questions

🎀 Decorators — Wrapping Without Inheritance

@ / functools.wraps / factory / class decorator

Level 0Curious
0 XP0/93 lessons0/23 achievements
0/100 XP to next level100 XP to go0% complete

Quiz

01What is @deco exactly equivalent to?
Hint
Decorators add NO new mechanism to the language — they're just function application with sugar.
02Why is @functools.wraps(fn) important on a wrapper?
Hint
What's hello.__name__ after @announce without wraps?
03How many levels of nested function does a decorator that takes arguments require?
Hint
Each pair of (...) in @retry(times=3) corresponds to one function call.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.