- Notifications
You must be signed in to change notification settings - Fork 7k
/
Copy pathchaining_method.py
37 lines (25 loc) · 712 Bytes
/
chaining_method.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from __future__ importannotations
classPerson:
def__init__(self, name: str) ->None:
self.name=name
defdo_action(self, action: Action) ->Action:
print(self.name, action.name, end=" ")
returnaction
classAction:
def__init__(self, name: str) ->None:
self.name=name
defamount(self, val: str) ->Action:
print(val, end=" ")
returnself
defstop(self) ->None:
print("then stop")
defmain():
"""
>>> move = Action('move')
>>> person = Person('Jack')
>>> person.do_action(move).amount('5m').stop()
Jack move 5m then stop
"""
if__name__=="__main__":
importdoctest
doctest.testmod()