Why needed decorators for changing a function? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why needed decorators for changing a function?

https://code.sololearn.com/cuFAk9YHrTEY/?ref=app Wrap function can get enother function as parameter and gives The same result

7th Jan 2018, 1:53 AM
Sergey Konkin
Sergey Konkin - avatar
2 Answers
+ 2
Here is an example of what a decorator may be useful for: https://code.sololearn.com/cD09ijlIS6Ev/?ref=app
25th Mar 2018, 4:34 PM
Denys Yeromenko
Denys Yeromenko - avatar
0
In this example it is not much difference. But think if your function print_text need parameters, the wrap function doesn't know that.
7th Jan 2018, 2:08 AM
Sebastián Zapata
Sebastián Zapata - avatar