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或更新版本。 –