Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Challenge: Argument Validation Decorator | Decorator Practice Lab
Quizzes & Challenges
Quizzes
Challenges
/
Python Decorators Explained

bookChallenge: Argument Validation Decorator

Tâche

Swipe to start coding

Create a decorator named positive_integer_args that checks all arguments passed to a function. The decorator must ensure every argument (both positional and keyword) is a positive integer. If any argument is not a positive integer, the decorator should raise a ValueError. Only if all arguments are valid should the original function execute.

Solution

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 4. Chapitre 1
single

single

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

Suggested prompts:

Can you explain this in simpler terms?

What are the main takeaways from this?

Can you give me an example?

close

bookChallenge: Argument Validation Decorator

Glissez pour afficher le menu

Tâche

Swipe to start coding

Create a decorator named positive_integer_args that checks all arguments passed to a function. The decorator must ensure every argument (both positional and keyword) is a positive integer. If any argument is not a positive integer, the decorator should raise a ValueError. Only if all arguments are valid should the original function execute.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 4. Chapitre 1
single

single

some-alt