Chapter 2
Answer 1
The chain of responsibility pattern inside Python allows us to build an application with loose coupling in mind. This is achieved by passing a received request through a chain of objects inside the software.
The following code snippet shows the implementation of the chain of responsibility pattern inside Python:
import abc
class Handler(metaclass=abc.ABCMeta):
"""Handler provides an interface to build handlers."""
def __init__(self, handler=None):
"""Initialize the handler.
Keyword arguments:
handler -- The next handler object to be called
"""
self._next_handler = handler
@abc.abstractmethod
def handler...