I'm learning Python and am up to decorators.
I'm trying to understand why they would be used.
If I code a veeeeeery simple decorator,
def new_func(inserted_func):
def wrap_func():
print("Start")
inserted_func()
print("End")
return wrap_func
@new_func
def existing_func():
print("Middle")
existing_func()
It will return,
Start
Middle
End
But I could also achieve the same thing by coding,
def func1():
print("Start")
def func2():
print("Middle")
def func3():
print("End")
func1()
func2()
func3()
Now I appreciate that my decorator function is very simple, but, other than "because you can", what are the reasons for choosing decorators over multiple functions?