ast.parse
Chris Rebert
clp2 at rebertia.com
Mon Apr 9 08:15:43 EDT 2012
On Mon, Apr 9, 2012 at 4:53 AM, Kiuhnm
<kiuhnm03.4t.yahoo.it at mail.python.org> 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?
What version of Python are you using? What's the exact error you're
getting? I'm unable to reproduce:
$ python3
Python 3.2.2 (default, Jan 13 2012, 00:07:49)
>>> c = """for (x,
... y) in each([1,
... 2]):
... print(1)"""
>>>
>>> from ast import parse
>>> parse(c)
<_ast.Module object at 0x101f38350>
>>>
Cheers,
Chris
More information about the Python-list
mailing list