ast.parse
Irmen de Jong
irmen.NOSPAM at xs4all.nl
Mon Apr 9 08:43:13 EDT 2012
On 9-4-2012 13:53, Kiuhnm wrote:
> Is it a known fact that ast.parse doesn't handle line continuations and some multi-line
> expressions?
> For instance, he doesn't like
> for (x,
> y) in each([1,
> 2]):
> print(1)
> at all.
> Is there a workaround besides "repairing" the code on the fly?
>
> Kiuhnm
What Python version are you using and what is the exact error? It works fine here
(Python 2.7.2):
>>> import ast
>>> code="""for (x,
... y) in each([1,
... 2]):
... print(1)"""
>>> ast.parse(code)
<_ast.Module object at 0x02418A10>
Irmen
More information about the Python-list
mailing list