Answer the question
In order to leave comments, you need to log in
How does it work(python,super)?
class Car:
def __init__(self, name, color, max_speed):
self.name = name
self.color = color
self.max_speed = max_speed
def info(self):
information = {'name': self.name, 'color': self.color, 'max_speed': self.max_speed}
return information
class Suv(Car):
def __init__(self, arg):
super(Suv, self).__init__() #Разве мы не должны переписывать инит полностью? обьясните как работает пожалуйста
self.arg = arg
Answer the question
In order to leave comments, you need to log in
In this case, it works like Car.__init__(self)
.
In general, super()
returns the class closest to the current one according to the MRO. Here seems to be a good article in Russian: https://habr.com/post/62203/.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question