I have a Parent and Child class as follows:
class Parent:
def __init__(self):
self.__set_config():
def __set_config(self):
raise NotImplementedError
def run(self):
# do something
class Child:
def __set_config(self):
self.config = {"foo": "bar"}
The expectation is that, in the parent class's call to __set_config()
, the child class's overridden method would be called. What in fact happens is that NotImplementedError
is raised instead of the config object being set.
Is it not possible to
- enforce implementation in a child class of a method,
- and also call the same method in the parent class?