Advertisement
ywandy

Untitled

Oct 15th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.40 KB | None | 0 0
  1. #!/usr/bin/python
  2. # -*- coding: UTF-8 -*-
  3. import time
  4.  
  5.  
  6. class LazyMan:
  7.     funclist = []
  8.     funclistkargs = []
  9.     funclistfirst = []
  10.     funclistfirstkargs = []
  11.  
  12.     def __init__(self, name):
  13.         self.intro(name=name)
  14.  
  15.     def intro(self, **kwargs):
  16.         self.funclist.append("_intro")
  17.         self.funclistkargs.append(kwargs)
  18.  
  19.     def _intro(self, **kwargs):
  20.         print("Hi This is {0}".format(kwargs["name"]))
  21.  
  22.     def eat(self, **kwargs):
  23.         self.funclist.append("_eat")
  24.         self.funclistkargs.append(kwargs)
  25.         return self
  26.  
  27.     def _eat(self, **kwargs):
  28.         print("Eat {0} ~".format(kwargs["text"]))
  29.  
  30.     def sleepFirst(self, **kwargs):
  31.         self.funclistfirst.append("_sleepFirst")
  32.         self.funclistfirstkargs.append(kwargs)
  33.         return self
  34.  
  35.     def _sleepFirst(self, **kwargs):
  36.         time.sleep(kwargs["sleeptime"])
  37.         print("睡眠了{0}秒".format(kwargs["sleeptime"]))
  38.  
  39.     def Exec(self):
  40.         for ind, fun_first in enumerate(self.funclistfirst):
  41.             fn = getattr(self, fun_first)
  42.             if fn != None:
  43.                 fn(**self.funclistfirstkargs[ind])
  44.         for ind, funs in enumerate(self.funclist):
  45.             fn = getattr(self, funs)
  46.             if fn != None:
  47.                 fn(**self.funclistkargs[ind])
  48.  
  49.  
  50. if __name__ == "__main__":
  51.     LazyMan("李逸炫").eat(text="supper").eat(text="eeee").Exec()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement