Код: Выделить всё
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def get_name(self):
print('My name is %s.'%self.name)
def get_age(self):
print('I am %d years old.'%self.age)
class Student(Person):
def __init__(self, name, age, GPA):
super().__init__(name, age)
self.GPA = GPA
def get_GPA(self):
print('My grade is %f.'%self.GPA)
Когда я создаю класс Student,
разве нельзя кодировать super().__init__ (self, name, age)?
Если нет, то какова точная причина, по которой «self» не следует добавлять в super().__init__(name, age)< /код>?
Подробнее здесь: https://stackoverflow.com/questions/793 ... hild-class
Мобильная версия