Sektion 4. Kapitel 4
single
Challenge: Conditional Decorator
Stryg for at vise menuen
Opgave
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.
Løsning
Var alt klart?
Tak for dine kommentarer!
Sektion 4. Kapitel 4
single
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat