Why does the Python interpreter show syntax errors on the following line? -


i've been helping new python user code, , asked me why python interpreter shows syntax errors on line after actual error. consider following code:

x = [1, 2, 3 print x 

a syntax error shown line print x, although error on previous line.

this can confusing (and time wasting) first time run it, common issue (search "python syntax error" on favourite search engine), , seems wouldn't difficult rectify... why hasn't been fixed? there benefit present approach?

it valid python syntax split list across multiple lines, like so:

x = [1, 2, 3 , 4, 5, 6] print x 

so, interpreter starts reading print... line expecting valid continuation of list, cannot find.

also, don't find terribly misleading. think it's pretty easy figure out why error.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -