Reputation: 9
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__
?
Upvotes: 0
Views: 47
Reputation: 530922
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)
# ...
Upvotes: 2