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

single

Challenge: Conditional Decorator

Svep för att visa menyn

Uppgift

Svep för att börja koda

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 desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 4. Kapitel 4
single

single

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

some-alt