Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. def executor(_):
  2.     def wrapper(self, *args, **kwargs):
  3.         command = args[0]
  4.         getattr(self, command)(*args[1:], **kwargs)
  5.     return wrapper
  6.  
  7.  
  8. class Commands:
  9.     @executor
  10.     def do(self, *args, **kwargs):
  11.         pass
  12.  
  13.     def svarit(self, count, sol=0):
  14.         print('varim', count)
  15.         print('sol', sol)
  16.  
  17.     def est(self, count, mayonaze=None):
  18.         print('em', count)
  19.         print('mayonaze', mayonaze)
  20.  
  21. c = Commands()
  22. pipeline = [
  23.     (('svarit', 5), {'sol': '2'}),
  24.     (('est', 4), {'mayonaze': True})
  25. ]
  26. for action in pipeline:
  27.     c.do(*action[0], **action[1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement