Zachary Ware added the comment:
The problem is, the interpreter can't know what you meant to do, so it can only
point out what it can't compile. We did recently add a special case for print
without parentheses, but adding special cases for everything is just not
feasible. Besides, where shou
Zack Weinberg added the comment:
In terms of the formal grammar of the language, you are correct. However, the
position of the caret should be chosen based *not* on the formal grammar, but
on a heuristic estimation of what the most probable mistake actually is. In
both of the cases I listed,
New submission from Zack Weinberg:
I tripped over a couple of SyntaxError cases where the diagnostic caret is
misplaced.
>>> While x:
File "", line 1
While x:
^
SyntaxError: invalid syntax
The caret should point to the capital W in 'While'.
>>> for x in