Section 4. Chapter 4
single
Challenge: Conditional Decorator
Swipe to show menu
Task
Swipe to start coding
Write a parameterized decorator that only allows a function to run if a given argument is True.
- If the parameter to the decorator is
True, call the decorated function and return its result. - If the parameter to the decorator is
False, do not call the decorated function andreturn Noneinstead. - Do not forget to return
decoratorandwrapperfunctions.
Solution
Everything was clear?
Thanks for your feedback!
Section 4. Chapter 4
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat