2
类
我想一些额外的属性添加到pyTree
node
类实现决策树算法。扩展新的风格
对于用户定义的内容,它只有一个data
属性,这也是使用类方法getNode(content)
时搜索的属性。我想在那里存储一个唯一的ID,但是也存储了用于树计算的其他属性。
我试着做各种各样的事情,但它从this post出现,下列应该是做的方式:
from pyTree.Tree import Tree
class decTree(Tree):
def __init__(self, val1, val2, data=None, children=None,):
super(decTree, self).__init__(data=None, children=None)
self.val1 = val1
self.val2 = val2
if __name__ == '__main__':
tree = decTree(val1=1.5, val2='string', data='567')
导致以下属性的错误:
TypeError: super() takes at least 1 argument (0 given)
有关执行此操作或其他事项需要考虑的任何建议都很棒。谢谢!
什么是异常的**完整**回溯?很显然'TypeError'不是源于你在这里使用'super()',你有两个参数。 –
'pyTree'需要Python 3或更新版本。 –