+ 1
Please can anyone explain these codes to me by each line by line. I didn't understand these codes after trying one day.
https://code.sololearn.com/ca5PX8diBjF1/?ref=app https://code.sololearn.com/c5jdikRodr4m/?ref=app
2 Answers
0
def decor(func):
    def wrap():
        print("============")
        func()
        print("============")
    return wrap
@decor
def print_text():
    print("Hello world!")
print_text() -> When we call this method, the decorator method will execute first, In this case, decor method: you are passing the print text as a func.  when we call the func() -> hello world because you are calling a function. We were wrapping this print text to decor
I go through your code
0
Why we return wrap and we unable to print the returned wrap and why wrap is used instead of wrap() in return.
And what about the first code.





