【发布时间】:2016-11-26 11:05:04
【问题描述】:
我问这个问题是因为我在谷歌上搜索过的关于该主题的所有其他页面似乎都变成了过于简单的案例或对超出范围的细节的随机讨论。
class Base:
def __init__(self, arg1, arg2, arg3, arg4):
self.arg1 = arg1
self.arg2 = arg2
self.arg3 = arg3
self.arg4 = arg4
class Child(Base):
def __init__(self, arg1, arg2, arg3, arg4, arg5):
super(Child).__init__(arg1, arg2, arg3, arg4)
self.arg5 = arg5
这是我尝试过的。我被告知我需要使用类型而不是 classobj,但我不知道这意味着什么,Google 也没有提供帮助。
我只是想让它工作。在 Python 2.7 中这样做的正确做法是什么?
【问题讨论】:
标签: python python-2.7 class arguments super