We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 93bfb7f + 4e62fd0 commit d4b7f97Copy full SHA for d4b7f97
patterns/behavioral/chaining_method.py
@@ -2,13 +2,12 @@
2
3
4
class Person:
5
- def __init__(self, name: str, action: Action) -> None:
+ def __init__(self, name: str) -> None:
6
self.name = name
7
- self.action = action
8
9
- def do_action(self) -> Action:
10
- print(self.name, self.action.name, end=" ")
11
- return self.action
+ def do_action(self, action: Action) -> Action:
+ print(self.name, action.name, end=" ")
+ return action
12
13
14
class Action:
@@ -26,8 +25,8 @@ def stop(self) -> None:
26
25
def main():
27
"""
28
>>> move = Action('move')
29
- >>> person = Person('Jack', move)
30
- >>> person.do_action().amount('5m').stop()
+ >>> person = Person('Jack')
+ >>> person.do_action(move).amount('5m').stop()
31
Jack move 5m then stop
32
33
0 commit comments