Using, python 3.4, that works:
>>> ast.literal_eval("2 - 1")
1
but that doesn't:
>>> ast.literal_eval("1 | 2")
raise ValueError('malformed node or string: ' + repr(node))
ValueError: malformed node or string: <_ast.BinOp object at 0x0000000003338978>
>>> ast.literal_eval("1 ^ 2")
raise ValueError('malformed node or string: ' + repr(node))
ValueError: malformed node or string: <_ast.BinOp object at 0x0000000003338400>
All values are literals, there's no difficulty performing logical operations when it can perform additions, substractions...
Why can't I perform logical operations using ast.literal_eval
?