New submission from Carl Friedrich Bolz-Tereick <[email protected]>:
A bit of a nitpick, but the following SyntaxError message is a bit confusing:
>>> f(True=1)
File "<stdin>", line 1
f(True=1)
^^^^^
SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
The problem with that line is not that it contains an assignment, it's almost a
valid keyword argument after all. The problem is that the name of the keyword
is True, which is no longer a name you can assign to. It would be better to
produce the same error as with __debug__:
>>> f(__debug__=1)
File "<stdin>", line 1
SyntaxError: cannot assign to __debug__
The latter error message is however produced by the compiler, not the parser I
think?
----------
messages: 405741
nosy: Carl.Friedrich.Bolz
priority: normal
severity: normal
status: open
title: Confusing parsing error message when trying to use True as keyword
argument
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue45716>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com