Guido van Rossum <[email protected]> added the comment:
Hmm... The errors get long, and by focusing only on keywords they can be
misleading. E.g.
>>> from x import a b c
File "<stdin>", line 1
from x import a b c
^
SyntaxError: Invalid syntax. Expected one of: as
>>>
But the most likely error is omission of a comma.
>>> if x y: pass
File "<stdin>", line 1
if x y: pass
^
SyntaxError: Invalid syntax. Expected one of: not, is, or, in, and, if
>>>
But the most likely error is probably a comparison operator.
And so on. Here's a nice one:
>>> /
File "<stdin>", line 1
/
^
SyntaxError: Invalid syntax. Expected one of: for, pass, lambda, False, global,
True, __new_parser__, if, raise, continue, not, break, while, None, del,
nonlocal, import, assert, return, class, with, def, try, from, yield
>>>
(Huh, where did it get __new_parser__?)
The beauty of Python's detail-free syntax error is that it doesn't tell you
what it expects -- because parsers are dumb, what the parser expected is rarely
what's wrong with your code -- and it requires the user to understand how the
parser works to interpret the error message.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue40599>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com