Dražen Lučanin added the comment:
Yes, I see your point.
Well, for now I am voting for issue1634034 to get some sort of
resolution, as Serhiy mentioned, as it might help this scenario as
well.
Cheers!
On Thu, Jan 10, 2013 at 4:29 PM, Ezio Melotti rep...@bugs.python.org wrote:
Ezio Melotti
New submission from Dražen Lučanin:
When running this script:
things = ['a', 'b']
things.append('c'
for a in things:
print a
I get the following output:
$ python script.py
File script.py, line 3
for a in things:
^
SyntaxError: invalid syntax
the SyntaxError is
Changes by Dražen Lučanin kermit...@gmail.com:
--
type: compile error - behavior
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16917
___
___
Ezio Melotti added the comment:
The colon is the first invalid char, for example this is valid python and works:
things = ['a', 'b']
things.append('c'
... for a in things)
things
['a', 'b', generator object genexpr at 0xb76dacfc]
In your case Python expects a genexp like things.append('c'
Mark Dickinson added the comment:
The error is in a missing parenthesis after the append call
Well, that's one *possible* cause of the error. But fixing that missing
parenthesis isn't the only way to make the code correct, and Python doesn't
have any reasonable way to guess which of the
Serhiy Storchaka added the comment:
For better syntax error messages see issue1634034.
--
nosy: +serhiy.storchaka
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16917
___
Dražen Lučanin added the comment:
Yes, sure, I agree with both comments. Fors are a bit disambiguous in
this context in comparison to while loops. But something in the style
of Ezio's explanation might come in handy in the error output.
e.g.
SyntaxError: invalid syntax. , or ) expected in the
Ezio Melotti added the comment:
This would all be a bit simpler if an indent was obligatory after
inserting a newline in the middle of a command.
This is not such a bad idea, but it is not backward-compatible and it would be
inconsistent with how parentheses works in other situations.