Skip to content

Latest commit

 

History

History
 
 

chapter06_command

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Chapter 6: Command design pattern

Command: Encapsulates a request as an object, thereby letting you parameterise clients with different requests, queue or log requests, and support undoable operations.

Use in Python

Threading In the Python standard library follows the command design pattern: The Client is the main thread and the receiver is the target thread. The Command is a callable Python object which is executed by calling its __call__() method. The Invoker is the Thread instance and its run() method is equivalent to calling execute in the Command pattern. Thread's run method can be overridden in subclasses to customise the functionality beyond simply providing a function and input args and kwargs.