python basis function parameters and return values decorator

1  # parameters and return values of the function decoration, on a blog about a parameter-free function and the use of programs written decorators, when the function has parameters and return values decoration requires repair will be issued on the following 
2  DEF Timer (Fun) :
 . 3      DEF Deco (* args, ** kwargs): # decorated function is actually performed deco, so this argument function to be decorated is passed 
. 4          START_TIME = the time.time ()
 . 5          RES = Fun (* args, ** kwargs) # to be decorated receiving the return value of the function 
. 6          stop_time = the time.time ()
 . 7          return RES # return value returns the decorative function 
. 8      return Deco
 . 9  
10 @timer # is decorated with function parameters and return values for explicit 
11  DEF the Add (X, Y):
 12 is     time.sleep(1)
13     print("this is add func")
14     return x+y
15 
16 print(add(1, 2))

 

Guess you like

Origin www.cnblogs.com/flags-blog/p/11925061.html