+ 1

Is there way to recover the non decorated function print_text() after decorating it with @decor?

25th Feb 2016, 2:26 PM
Lars
Lars - avatar
3 ответов
+ 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.
26th Apr 2016, 10:39 AM
Andy
+ 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
14th Jul 2016, 3:37 AM
eduardotomassi
eduardotomassi - avatar
+ 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
11th Oct 2016, 3:58 PM
Bart Genuit
Bart Genuit - avatar