Serhiy Storchaka added the comment:
No it doesn't support all Python operators.
>>> ast.literal_eval('2*3')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.4/ast.py", line 84, in literal_eval
return _convert(node_or_string)
File "/usr/lib/python3.4/ast.py", line 83, in _convert
raise ValueError('malformed node or string: ' + repr(node))
ValueError: malformed node or string: <_ast.BinOp object at 0xb6f8446c>
And shouldn't. It supports "+" and "-" only because they are needed for support
of complex "literals". It is unintentional side effect, that ast.literal_eval()
supports not only "2+3j", but "2+3" too.
----------
nosy: +mark.dickinson, serhiy.storchaka
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue24146>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com