子类继承父类的时候 需要把父类里面的所有参数写一遍吗?那要是多重继承 祖先类的 入参怎么写?
class Person(object):
def __init__(self, name, gender):
self.name = name
self.gender = gender
class Student(Person):
def __init__(self, name, gender, score):
super(Student, self).__init__(name, gender)
self.score = score
class Boos(object):
def __init__(self, boosName, boosGender):
self.boosName = boosName
self.boosGender = boosGender
class Teacher(Student,Boos):
def __init__(self, name, gender, score,course,boosName, boosGender):
super(Teacher, self).__init__(name, gender, score,boosName, boosGender)
self.course = course
问题1: 多重继承的时候super(Teacher, self).__init__(name, gender, score,boosName, boosGender)
Student __init__(self, name, gender, score)
Boos __init__(self, boosName, boosGender)
父类接受参数的是后是按顺序接收的不能对应到我传的参数吧?
结果
boosName --> name
boosGender --> gender
问题2: 这样递增的入参有没有好的写法呢?一个类里面有几十个参数的话是不是得每个参数都要传?