Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ast.parse

29 views
Skip to first unread message

Kiuhnm

unread,
Apr 9, 2012, 7:53:21 AM4/9/12
to
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

Irmen de Jong

unread,
Apr 9, 2012, 8:43:13 AM4/9/12
to
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

Kiuhnm

unread,
Apr 9, 2012, 9:57:59 AM4/9/12
to
Yes, it works. I was too hasty in blaming ast. Sorry.

Kiuhnm
0 new messages