Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # -*- coding: UTF-8 -*-
- import time
- class LazyMan:
- funclist = []
- funclistkargs = []
- funclistfirst = []
- funclistfirstkargs = []
- def __init__(self, name):
- self.intro(name=name)
- def intro(self, **kwargs):
- self.funclist.append("_intro")
- self.funclistkargs.append(kwargs)
- def _intro(self, **kwargs):
- print("Hi This is {0}".format(kwargs["name"]))
- def eat(self, **kwargs):
- self.funclist.append("_eat")
- self.funclistkargs.append(kwargs)
- return self
- def _eat(self, **kwargs):
- print("Eat {0} ~".format(kwargs["text"]))
- def sleepFirst(self, **kwargs):
- self.funclistfirst.append("_sleepFirst")
- self.funclistfirstkargs.append(kwargs)
- return self
- def _sleepFirst(self, **kwargs):
- time.sleep(kwargs["sleeptime"])
- print("睡眠了{0}秒".format(kwargs["sleeptime"]))
- def Exec(self):
- for ind, fun_first in enumerate(self.funclistfirst):
- fn = getattr(self, fun_first)
- if fn != None:
- fn(**self.funclistfirstkargs[ind])
- for ind, funs in enumerate(self.funclist):
- fn = getattr(self, funs)
- if fn != None:
- fn(**self.funclistkargs[ind])
- if __name__ == "__main__":
- LazyMan("李逸炫").eat(text="supper").eat(text="eeee").Exec()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement