Nov-09-2023, 09:55 AM
hi
in below code:
the order of running lines was: 4,13,14,13,5,6,11,14,20,23,24,21,25,7,8,15,18,9,10 .
the above code is a decorator function. why the order of running lines is as above line? plz, explain.
thanks
in below code:
# from:https://python.coderz.ir/lessons/l14-recursive- \ # functions-and-memoization-in-python.html def logger(func): print('Decorator is created!') def func_wrapper(number): print(f'New factorial call with parameter: {number}') result = func(number) print (f'factorial({number}) ==> {result}') return result return func_wrapper @logger def factorial(n): if n <= 1: return 1 else: return n #* factorial(n - 1) def test(): print("it is a test") if __name__=="__main__" : test() print(f"factoril(5) is : {factorial(5)}")I ran and debugged the above code in idle.
the order of running lines was: 4,13,14,13,5,6,11,14,20,23,24,21,25,7,8,15,18,9,10 .
the above code is a decorator function. why the order of running lines is as above line? plz, explain.
thanks