Итак, если у меня есть класс:
class Person(object):
'''A class with several methods that revolve around a person Name and Age.'''
def __init__(self, name = 'Jane Doe', year = 2012):
'''The default constructor for the Person class.'''
self.n = name
self.y = year
И затем этот подкласс:
class Instructor(Person):
'''A subclass of the Person class, overloads the constructor with a new parameter.'''
def __init__(self, name, year, degree):
Person.__init__(self, name, year)
Я немного потерял, как заставить подкласс вызвать и использовать конструктор родительского класса для name
и year
, добавив в подкласс новый параметр degree
.