defprotect(*protected): """Returns a metaclass that protects all attributes given as strings""" classProtect(type): has_base = False def__new__(meta, name, bases, attrs): if meta.has_base: for attribute in attrs: if attribute in protected: raise AttributeError('Overriding of attribute "%s" not allowed.'%attribute) meta.has_base = True klass = super().__new__(meta, name, bases, attrs) return klass return Protect