I have a tree structure stored in a text file. I want to read the file into Python and convert it into a Node object.
The standard way to build the tree is as follows:
from zss import Node
A = (
Node("+")
.addkid(Node("+")
.addkid(Node("2"))
.addkid(Node("4")))
.addkid(Node("*")
.addkid(Node("3"))
.addkid(Node("5")))
)
Now I have the structure stored in a text file. e.g. A.txt
Node("+")
.addkid(Node("+")
.addkid(Node("2"))
.addkid(Node("4")))
.addkid(Node("*")
.addkid(Node("3"))
.addkid(Node("5")))
Is there a way to read A.txt into python as an object of class Node? I tried converting the file into a .py file and reading in however it was not successful?