Guest User

Untitled

a guest
Oct 22nd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. def guarded(*guard_func):
  2.     def decor(func_m1):    
  3.         def guard(*param):
  4.             if guard_func[1](*param):
  5.                 guard.i=(guard.i+1) % 2
  6.                 if guard.i==0:
  7.                     return func_m1(*param)
  8.             else:
  9.                 print("parametri non rispettati")
  10.                
  11.         guard.i=0
  12.            
  13.         return guard
  14.     return decor
  15.        
  16.                
  17. @guarded(2, lambda x,y,z: (x+y)==z)
  18. def m1(x,y,z):
  19.     print("sto eseguendo m1 con i valori {0}{1}{2}".format(x,y,z))
Add Comment
Please, Sign In to add comment