+ 8
why do we use decorators and I really don't understand this properties ! could anyone explain it
7 ответов
+ 6
It lets you write smaller, more reusable functions. You can write a whole program as one function, but that is a terrible idea. Likewise, small functions are generally better than large ones. Using decorators is one way you can split a function that does two things, that prints text and prints a border, into two functions -- one that prints text and one that wraps printed text in a border.
+ 2
Here is an example of what a decorator may be useful for:
https://code.sololearn.com/cD09ijlIS6Ev/?ref=app
0
As someone writing a MUD, decorators could be handy for outputting texts like articles within decorated boundaries.
0
answer plz?
- 3
to spice up our functions
- 4
it just a way to extend any function's functionality without actually updating it...
- 6
Save memory