Closed
Description
current scenario -
let us take PEP-572,
in
https://peps.python.org/pep-0572/#scope-of-the-target
it has some code like this,
[[(j := j) for i in range(5)] for j in range(5)] # INVALID
[i := 0 for i, j in stuff] # INVALID
[i+1 for i in (i := stuff)] # INVALID
but it does not specify what error will be raised for these.
expected scenario -
the error message is also described in the pep.
so, the above would become,
[[(j := j) for i in range(5)] for j in range(5)] # INVALID
raises,
SyntaxError: assignment expression cannot rebind comprehension iteration variable 'j'
[i := 0 for i, j in stuff] # INVALID
raises,
SyntaxError: assignment expression cannot rebind comprehension iteration variable 'i'
[i+1 for i in (i := stuff)] # INVALID
raises,
SyntaxError: assignment expression cannot be used in a comprehension iterable expression
in case there are multiple statements which raise the same error message, then could use like,
statement_1 # INVALID
statement_2 # INVALID
both of the above raise,
error_type: error_message
motivation -
it becomes easier to reverse search, like if I get an error, then I could search for it in the pep, and the associated explanation.