[Python-Dev] Assign(expr* targets, expr value) - why targetS?

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Nov 12 08:14:30 CET 2013

anatoly techtonik wrote:
> where is code that validates that the structure is correct? Is it done
> on the first level - text file parsing, before ASDL is built? If so,
> then what is the role of this ADSL exactly that the first step is
> unable to solve?

I think it's done by the code that traverses the AST and
generates bytecode. It complains if it comes across something
that it doesn't know how to generate assignment code for.

The reason it's done this way is that Python's LL parser
can't see far enough ahead to know that it's processing
an assignment until it has parsed the whole LHS and gets
to the '='. Up to that point, it could well be just
something to be evaluated, so it has to accept a general

I suppose a validation step could be performed before
putting it into the AST, but there's no point, because
the problem will become obvious during code generation


More information about the Python-Dev mailing list