in this example :
class Dinosaur:
def __init__(self, size, weight):
self.size = size
self.weight = weight
class Carnivore:
def __init__(self, diet):
self.diet = diet
class Tyrannosaurus(Dinosaur, Carnivore):
def __init__(self, size, weight, diet):
Dinosaur.__init__(self, size, weight)
Carnivore.__init__(self, diet)
tiny = Tyrannosaurus(12, 14, "whatever it wants")
i have to mention "self" in both
Dinosaur.__init__(self, size, weight)
Carnivore.__init__(self, diet)
or i get an error.
but in single inheritance
class Person():
def __init__(self, name, age, occupation):
self.name = name
self.age = age
self.occupation = occupation
class Superhero(Person):
def __init__(self, name, age, occupation, secret_identity):
super().__init__(name, age, occupation)
self.secret_identity = secret_identity
i didn't have to mention self in the init method
super().__init__(name, age, occupation)
i'm wondering what is exactly going on under the hood that returns from super().init(...) without mentioning "self"
and what is going on in multiple inheritance that i HAVE to use "self" or i get an error