Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Conditional Decorator | Mastering Python Decorators
Functional Programming Concepts in Python
Sektion 4. Kapitel 4
single

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 and return None instead.
  • Do not forget to return decorator and wrapper functions.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 4. Kapitel 4
single

single

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

some-alt