asciitree
asciitree copied to clipboard
Identical children
I was thinking of using asciitree
to represent arithmetic expressions as trees, eg (2 * 2)
:
*
+-- 2
+-- 2
But this seems not to work, because one 2
overwrites the other, in the OrderedDict
.
Here is my code:
from asciitree import LeftAligned
from collections import OrderedDict as OD
tree = {
'*': OD([
('2', {}),
('2', {})
])
}
tr = LeftAligned()
print(tr(tree))
and output:
*
+-- 2
I guess the workaround would be to invent unique names for each 2
?