I have a base class which is never going to be instantiated. There are different subclasses of this base class. Each subclass defines certain class variables where the name is same across all subclasses but the value is going to be different. For example
class Base:
def display(self):
print self.logfile, self.loglevel
class d1(Base):
logfile = "d1.log"
loglevel = "debug"
def temp(self):
Base.display(self)
class d2(Base):
logfile = "d2.log"
loglevel = "info"
def temp(self):
Base.display(self)
What is the right way to design this such that I can enforce that if tomorrow any new subclass is defined, the person implementing the subclass should provide some values to these class variables and not miss defining them ?
One alternative that doesn’t require instantiating the classes for the checking to take place is to create a metaclass: