Decorators but I have not learn *rags and **kwargs | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
- 1

Decorators but I have not learn *rags and **kwargs

You are working on an invoicing system. The system has an already defined invoice() function, which takes the invoice number as argument and outputs it. You need to add a decorator for the invoice() function, that will print the invoice in the following format: Sample Input 42 Sample Output *** INVOICE #42 *** END OF PAGE

7th Jul 2021, 2:55 PM
Riyaz soni
2 Réponses
+ 1
Maybe.... Two approaches: with functions and callable classes https://code.sololearn.com/c913zKznJuRW/?ref=app
7th Jul 2021, 4:05 PM
David Ordás
David Ordás - avatar
0
https://code.sololearn.com/cc5FLjNzarjD/?ref=app there are some variants but it does the job. The deco function takes a function func as parameter. It doesn't care for the parameters of the decorated function. The inner function of deco must have same parameters as the decorated function. So it can call func. Many apply that pattern with rough understanding. It is okay and understanding will come sooner or later.
7th Jul 2021, 3:53 PM
Oma Falk
Oma Falk - avatar