[Python-Dev] statically nested scopes

Guido van Rossum guido@python.org
Thu, 02 Nov 2000 01:02:10 -0500

> If we get lexical scoping, there should be a fast (built-in) way to
> get at all the accessible names from Python.  I.e. currently I can do
>     d = globals().copy()
>     d.update(locals())
> and know that `d' contains a dictionary of available names, with the
> right overloading semantics.  (PEP 42 now includes a feature request
> to make vars() do this by default.)

Note that I just deleted that feature request from PEP 42 -- vars() or
locals() returns the dictionary containing the variables, and you
can't just change the semantics to return a newly copied dictionary
(which could be quite expensive too!).

I don't think you need to have a mechanism to find all accessible
names; I don't see a common use for that.  It's sufficient to have a
mechanism to look up any specific name according to whatever mechanism
we decide upon.  This is needed for internal use of course; it can
also be useful for e.g. variable substitution mechanisms like the one
you recently proposed or Ping's Itmpl.

--Guido van Rossum (home page: http://www.python.org/~guido/)