I've been helping a new Python user with some code, and he asked me why the python interpreter shows some syntax errors on the line after the actual error. Consider the following code:
x = [1, 2, 3
print x
A syntax error will be shown for the line with print x, although the error is really on the previous line.
This can be very confusing (and time wasting) the first time you run into it, it is a very common issue (search for "python syntax error" on your favourite search engine), and it seems like it wouldn't be difficult to rectify... why hasn't it been fixed? Is there some benefit to the present approach?
]on line 2, this is valid syntax. So there's nothing wrong with line 1.x = [1, 2, 3, print]and were doingxon a line by itself...