asciitree icon indicating copy to clipboard operation
asciitree copied to clipboard

Identical children

Open jmmcd opened this issue 4 years ago • 0 comments

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?

jmmcd avatar Mar 01 '20 23:03 jmmcd