On Thu, 09 Oct 2008 13:26:17 +0100, Orestis Markou wrote:
in python 2.6, ast.literal_eva l may be used to replace eval() for
literals. It does not accepts statements and function calls, i.e.:
set([1, 2, 3])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/ast.py", line 67, in literal_eval
return _convert(node_o r_string)
File "/usr/local/lib/python2.6/ast.py", line 66, in _convert
raise ValueError('mal formed string')
ValueError: malformed string
The ast module in 2.6 has something...
>
>
literals. It does not accepts statements and function calls, i.e.:
>>a = set([1, 2, 3])
>>repr(a)
>>repr(a)
>>ast.literal_e val(repr(a))
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/ast.py", line 67, in literal_eval
return _convert(node_o r_string)
File "/usr/local/lib/python2.6/ast.py", line 66, in _convert
raise ValueError('mal formed string')
ValueError: malformed string
Comment