Изучаю Python, написал вот такой код:
class Person:
def __init__(self, name):
self.name = name
def ShowData(self):
print (self.name)
class Student(Person):
def __init__(self, name, education):
# super().__init__(self, name)
self.education = education
class Worker(Person):
def __init__(self, workPlace):
self.workPlace = workPlace
class Academy:
def __init__(self):
# при создании объекта инициализируем пустой список
self.persons = []
def show_all(self):
# Output collection
for pers in self.persons:
for atr in dir(pers):
if atr == 'education':
print(pers.name, pers.education)
elif atr == 'work_place':
print(pers.name, pers.work_place)
else:
continue
print(pers.name)
def AddPerson(self,pers):
# Добавляем объект в коллекцию
self.persons.append(pers)
Подскажите как унаследовать конструктор класса
Person
так, чтобы работал следующий код:
man = Person("Mark")
st = Student("Deyve", "History")
#man.ShowData()
print("_________________")
nmu = Academy()
nmu.AddPerson(man)
nmu.AddPerson(st)
nmu.ShowAll()
На данном этапе ошибка:
Traceback (most recent call last):
File "python", line 35, in <module>
File "python", line 23, in ShowAll
AttributeError: 'Student' object has no attribute 'name'