I’ve been sitting and staring myself blind on super() as it seems so easy, but there is something that i can’t get to ‘click’
class Person(object): #person is-a instance of the object class def __init__(self, name): self.name = name #person has-a name self.pet = None #person has-a pet of some kind class Employee(Person): #Employee is-a instance of Person def __init__(self, name, salary): #https://www.pythonforbeginners.com/super/working-python-super-function super().__init__(name) #the super parent is used to reach back to a parent self.salary=salary #Employee has-a salary frank = Employee('Frank', 120000) #frank is as a Employee with the name Frank and salary of 120000 frank.pet=rover print(frank.name) #output: Frank print(frank.pet.name) #output: Rover
I understand how frank.salary = 12000
I think I understand how frank.name = ‘Frank’ because Person.name is accessed through the super.init(name)
Where Im lost is how I get access to the Person.pet setting through the super(). My brain wants it to be something like super.init(name, pet)?