On Dec 8, 12:20 am, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > "MonkeeSage" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > | 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.
I see. > | 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. It would pretty much be pointless. Referencing a name before it's assigned seems confusing and strange to me. I suppose one sane use would be in implementing something like Haskell's "where" clause, but I don't think that would work well (or even be very useful) in python. Anyhow, this was more of an academic curiosity on how CPython does things, and I appreciate your answers. > tjr Regards, Jordan -- http://mail.python.org/mailman/listinfo/python-list