Abstract classes with varying amounts of parameters

No checks are done on how many arguments concrete implementations take. So there is nothing stopping your from doing this already.

Just define those methods to take whatever parameters you need to accept:

class View(metaclass=ABCMeta):
    @abstractmethod
    def set(self):
        pass

    @abstractmethod
    def get(self):
        pass


class ConcreteView1(View):
    def set(self, param1):
        # implemenation

    def get(self, param1, param2):
        # implemenation


class ConcreteView2(View):
    def set(self):
        # implemenation

    def get(self, param1, param2):
        # implemenation

Leave a Comment