Friday, December 27, 2019

Python : Interface Segregation

Python : Interface Segregation


class Printer:
    @abstractmethod    def print(self, document): pass
class Scanner:
    @abstractmethod    def scan(self, document): pass


class MyPrinter(Printer):
    def print(self, document):
        print(document)

class Photocopier(Printer, Scanner):
    def print(self, document):
        print(document)

    def scan(self, document):
        pass  # something meaningful

No comments:

Post a Comment