So I have this class, lets call it BaseClass
from abcmeta import ABC, abstractmethod
class BaseClass(ABC):
@abstractmethod
def load_configs():
pass
class Inherited1(BaseClass)
def load_configs(self):
do_stuff() # This is where the meat and potatoes happen(s).
class Inherited2(Inherited1):
.
.
.
So, I’m good implementing the load_config() in Inherited1. That is where the actions need to be performed. But if I have another layer in the heirarchy, inherited2(), I’d really rather not have to implement that method again. And if someone on this project adds an inherited3 (another layer) I don’t want them to have to implement it.
Is there any way around this?
This is the error I get when I don’t implement it in Inherited2
AttributeError:
1: incorrect implementation.
Derived class ‘Inherited2’ has not implemented ‘load_configs’ method of the parent class ‘BaseClass’
I’m willing to learn, if there is a better way to approach this, too.
Brian Luckau is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1