Answer 3

It's quite easy to define a new abstract class using the ABC metaclass. The following code snippet shows an example of achieving this kind of behavior:

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(self, data):
"""The handler abstract method.

Keyword arguments:
data -- The data to be processed by the handler
"""

pass
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.2.240