I have a string expression like "((12)*2+(12)+0)"
.
The question is I want to calculate this expression.
I can use eval()
function. Is there any other way?
I also checked ast=compiler.parse(eq)
and it return Module(None, Stmt([Discard(Add((Add((Mul((Const(12), Const(2))), Const(12))), Const(0))))]))
something like that.
How to parse abstract syntax tree?