Very headache questions
I have seen the code as bellow (in the Python lesson of Sololearn): def decor(func): def wrap(): #Question1: Why we have to add a function of wrap() inside the function of decor() print("============") func() print("============") return wrap #Question2: Why we have to add a return here, what's this exact meaning, and why we can't just write: "return" ? def print_text(): print("Hello world!") a=decor(print_text) a() #Question3: Why we can't just put "print(a)" here ? And why we have to put "()" after "a" ? >>>>OUTPUT: ============ Hello world! ============ I have 3 questions: Question1: Why we have to add a function of wrap() inside the function of decor() Question2: Why we have to add a return at end of loop, what's this exact meaning, and why we can't just write: "return" ? Question3: Why we can't just put "print(a)" at end ? And why we have to put "()" after "a" ?