+ 1
Is there way to recover the non decorated function print_text() after decorating it with @decor?
3 Respuestas
+ 1
You can use
decor(print_text)()
to make an new, decorated funktion and call the new made funktion a single time without changing print_text. But the new made funktion will not be saved in the sense of that you have to type decor(print_text)() every time you want to use the decorated funktion.
Or you can do sth like
def new_print_text ():
decor(print_text)()
new_print_text()
or like
new_print_text = decor(print_text)
new_print_text ()
to define and call the decorated function without touching print_text.
+ 1
no you can't. your function will be used as a parameter of another function. you will have to save your original function in a variable before decorating it, as Andy said
+ 1
I guess you could use debugging tools to create a 'stack trace', a list of the subroutines in the order they're called at a certain point in the program