[Python-Dev] Nested scopes resolution -- you can breathe again!

Jeremy Hylton jeremy@alum.mit.edu
Thu, 22 Feb 2001 22:15:39 -0500 (EST)


>>>>> "GvR" == Guido van Rossum <guido@digicool.com> writes:

  GvR> The Python equivalent of this is a magical import that is
  GvR> recognized by the compiler; this was also proposed by David
  GvR> Scherer for making integer division yield a float.  (See
  GvR> http://mail.python.org/pipermail/edu-sig/2000-May/000499.html)
  GvR> You could say that Perl's "use" statement is similar.

  GvR> We haven't decided yet which magical import; two proposals are:

  GvR>     import __nested_scopes__ from __future__ import
  GvR>     nested_scopes

  GvR> The magical import only affects the source file in which it
  GvR> occurs.  It is recognized by the compiler as it is scanning the
  GvR> source code.  It must appear at the top-level (no "if" or "try"
  GvR> or "def" or anything else around it) and before any code that
  GvR> could be affected.

We'll need to write a short PEP describing this approach and offering
some guidance about how frequently we intend to use it.  I think few
of us would be interested in making frequent use of it to add all
sorts of variant language features.  Rather, I imagine it would be
used only -- or primarily -- to introduce new features that will
become standard at some point.

  GvR> We also believe that the magical import mechanism is useful
  GvR> enough to be reused for other situations like this; Tim will
  GvR> draft a PEP to describe in excruciating detail.

I'm happy to hear that Tim will draft this PEP.  He didn't mention it
at lunch today or I would have given him a big hug (or bought him a
Coke).  As Tim knows, I think the PEP needs to say something about
whether these magic imports create name bindings and what objects are
bound to the names.

Will we need an __nested_scopes__.py in the Lib directory?

Jeremy