Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Challenge: Conditional Decorator | Mastering Python Decorators
Functional Programming Concepts in Python
Osio 4. Luku 4
single

single

Challenge: Conditional Decorator

Pyyhkäise näyttääksesi valikon

Tehtävä

Pyyhkäise aloittaaksesi koodauksen

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.

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 4. Luku 4
single

single

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

some-alt