Hello.
This is my code:
class Node:
def __init__(self, tag, value=None, **kwargs):
self.tag = tag
self.value = value
self.kwargs = kwargs
self.childs = [] def addChild(self, tag, value=None, **kwargs):
node = Node(tag, value, kwargs)
self.childs.append(node)def __repr__(self):
return "Tag %s ; value %s ; kwargs %s ; childs %s" % (self.tag, self.value, self.kwargs, self.childs)
And this is what I do to test it:
>>> ppal = Node("Test", value="Test")
>>> ppal.addChild("test", value=2)
Traceback (most recent call last):
File "<pyshell#75>", line 1, in -toplevel-
ppal.addChild("test", value=2)
File "...node.py", line 10, in addChild
node = Node(tag, value, kwargs)
TypeError: __init__() takes at most 3 arguments (4 given)I don't understand. Why 4 arguments are given? What can I do to solve that?
The idea of the class is to be able to create a "tree". Where each node can have subnodes, which in turn can have their subnodes...
Thanks Ismael
_______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
