How does python build its AST

Terry Reedy tjreedy at udel.edu
Sat Dec 8 01:20:15 EST 2007


"MonkeeSage" <MonkeeSage at gmail.com> wrote in message 
news:7e222fec-8b84-49d7-a9bc-113520d7ed91 at t47g2000hsc.googlegroups.com...
| 1.) What is the benefit of doing a two phase compilation (parsing/
| compiling), rather than a single, joint parse + compile phase (as in
| interactive mode)?

As far as I know (without looking at the code), there is no difference 
between interactive and batch mode except that the unit processed is a 
statement versus file.

| 2.) Wouldn't it be possible on the parsing phase to "tag" names as
| valid, even if they occur prior to the assignment of the name, if on a
| later branch that assignment is found (and have the compiler be aware
| of such tags)?

What would be the point?  The semantics of Python code is essentially 
independent of whether it is executed in interactive or batch mode.  (The 
exceptions are not relevant to your question.)  So there is no point I can 
see to doing something in file mode that could not be done in statement 
mode.

tjr 






More information about the Python-list mailing list