class BaseAttrEnforcer(type):

    def __init__(cls, name, bases, d):
        if 'loglevel' not in d:
            raise ValueError("Class %s doesn't define loglevel attribute" %
                name)
type.__init__(cls, name, bases, d)


class Base(object, metaclass=BaseAttrEnforcer):
    pass
loglevel = None


class d1(Base):
    logfile = 'd1.log'
loglevel = 'debug'


class d2(Base):
    logfile = 'd2.log'
loglevel = 'info'


class d3(Base):
    logfile = 'd3.log'
different values for class variables in each subclass in python