here' the uml diagramcommandinterface +execute(invoker client command +execute(receiver common example of the command pattern is actions on graphical window oftenan action can be invoked by menu item on the menu bara keyboard shortcuta toolbar iconor context menu these are all examples of invoker objects the actions that actually occursuch as exitsaveor copyare implementations of commandinterface gui window to receive exita document to receive saveand clipboardmanager to receive copy commandsare all examples of possible receivers let' implement simple command pattern that provides commands for save and exit actions we'll start with some modest receiver classesimport sys class windowdef exit(self)sys exit( class documentdef __init__(selffilename)self filename filename self contents "this file cannot be modifieddef save(self)with open(self filename' 'as filefile write(self contentsthese mock classes model objects that would likely be doing lot more in working environment the window would need to handle mouse movement and keyboard eventsand the document would need to handle character insertiondeletionand selection but for our example these two classes will do what we need