Bug report
Today I made a typo: instead of in I wrote if.
I was quite interested to see the error message:
>>> [x for x if range(1)]
File "<stdin>", line 1
[x for x if range(1)]
^^^^^^^^^^^^^
SyntaxError: expected 'else' after 'if' expression
I don't think that this error message is correct. Why? Because even if we follow the rabbit hole and use else, we won't be ever correct:
>>> [x for (x if range(1) else y) in range(1)]
File "<stdin>", line 1
[x for (x if range(1) else y) in range(1)]
^^^^^^^^^^^^^^^^^^^^
SyntaxError: cannot assign to conditional expression
So, maybe we should change it to be something like:
>>> [x for x if range(1)]
File "<stdin>", line 1
[x for x if range(1)]
^^
SyntaxError: expected 'in', got 'if'
Suggestions about wording are welcome :)
If others agree, I would like to work on this.
Linked PRs
Bug report
Today I made a typo: instead of
inI wroteif.I was quite interested to see the error message:
I don't think that this error message is correct. Why? Because even if we follow the rabbit hole and use
else, we won't be ever correct:So, maybe we should change it to be something like:
Suggestions about wording are welcome :)
If others agree, I would like to work on this.
Linked PRs