0

So I have an abstract class which has one non-abstract (concrete) method:

class abstract_class(ABC):
    def __init__(self) -> None:
        self.a = 0
        self.b = 0

    def new_method(self):
        self.a = 1
        self.b  = 1

Now, I have another abstract class, which inherits from the abstract_class:

class inherited_class (ABC, abstract_class):
    def __init__(self) -> None:
        super().__init__()
        self.c = 0

    def new_method(self):
    #to_do

Here is my question: both "new_method" methods are concrete. I want the second new_method to do everything the super class's new_method does, and in addition to that, does also this: self.c = 1

What is the best way to achieve that?

I tried this:

    def new_method(self):
        self.a = 1
        self.b  = 1
        self.c = 1

But I doubt if it's the best idea.

kalike5373
  • 13
  • 3
  • 1
    Just like how you called the parent class' `__init__`: Call the parent class' `super().new_method()`, followed by your `inherited_class` specific code? – Paul M. Apr 11 '23 at 01:44

0 Answers0