how to create root with treelib?

dieter dieter at handshake.de
Mon Aug 21 03:14:26 EDT 2017


Ho Yeung Lee <jobmattcon at gmail.com> writes:

> http://treelib.readthedocs.io/en/latest/examples.html
>
> tree = Tree()
> #create root
> tree.create_node((0,0), "root")
> result = [aa[0]]
> previousnode = (0,0)
>
>>>> #create root
> ... tree.create_node((0,0), "root")
> Traceback (most recent call last):
>   File "<stdin>", line 2, in <module>
>   File "C:\Python27\lib\site-packages\treelib\node.py", line 142, in __repr__
>     "tag=%r" % self.tag,
> TypeError: not all arguments converted during string formatting

Check the code of "treelib.node" near line 142 in order to determine
where the value for the attribute "tag" comes from.

Your error message suggests that "tag" might have gotten its value
from the first parameter of "create_node". In this case, "self.tag"
would be a tuple of 2 elements and the above error would occur because
the pattern has a specification for a single element.
In this case, do not pass tuples as first parameter to "create_node"
(but strings).




More information about the Python-list mailing list