0

In Python, I'm using inheritance for a class. The initial init for the main parent class is below:

def __init__(self, Date = None):
    self.Date = Date
    self.DatabaseClass = Database()
    self.Connection = self.DatabaseClass.databaseConnection()

I've inherited the class into the child class, but am wondering what the correct approach would be to inherit DatabaseClass and Connection variables, i.e., what would be in def __init__?

2
  • What inheritance do you mean? I only see composition Commented Mar 4, 2019 at 0:57
  • Could you show the definition of the classes? Commented Mar 4, 2019 at 0:57

1 Answer 1

2

You just need to call the inherited __init__ method from your own class's __init__ method.

class Child(Parent):
    def __init__(self, Date=None, other, arguments):
        super().__init__(Date)
        # ...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.