[英]Calling Parent __init__()
我使用的是Python 2.6.6。
我已将我的错误代码缩小到这两个类:
class Graph(object):
def __init__(self, name):
self.name = name
self.testme = 3
和
class StepPlot(Graph):
def __init__(self, name):
print("fdasfdsf")
print(dir(super(Graph, self)))
super(Graph, self).__init__(name)
不幸的是,当我使用StepPlot('fdsfa')
实例化StepPlot
时,我得到了错误
TypeError: object.__init__() takes no parameters
它不应该能够采取一个参数?
看着
何时调用Python的super().__ init __()?
这个班级组织应该工作。
我是否从根本上遗漏了一些东西? 任何帮助,将不胜感激。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.