Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions patterns/behavioral/chaining_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@


class Person:
def __init__(self, name: str, action: Action) -> None:
def __init__(self, name: str) -> None:
self.name = name
self.action = action

def do_action(self) -> Action:
print(self.name, self.action.name, end=" ")
return self.action
def do_action(self, action: Action) -> Action:
print(self.name, action.name, end=" ")
return action


class Action:
Expand All @@ -26,8 +25,8 @@ def stop(self) -> None:
def main():
"""
>>> move = Action('move')
>>> person = Person('Jack', move)
>>> person.do_action().amount('5m').stop()
>>> person = Person('Jack')
>>> person.do_action(move).amount('5m').stop()
Jack move 5m then stop
"""

Expand Down