[Python-Dev] statically nested scopes

Guido van Rossum guido@python.org
Thu, 02 Nov 2000 00:56:03 -0500

[Jeremy and Tim argue about what to do about write access for
variables at intermediate levels of nesting, neither local nor

I'll risk doing a pronouncement, even though I know that Jeremy (and
maybe also Tim?) disagree.

You don't need "write access" (in the sense of being able to assign)
for variables at the intermediate scopes, so there is no need for a
syntax to express this.  Assignments are to local variables (normally)
or to module-globals (when 'global' is used).  Use references search
for a local, then for a local of the containing function definition,
then for a local in its container, and so forth, until it hits the
module globals, and then finally it looks for a builtin.

We can argue over which part of this is done statically and which part
is done dynamically: currently, locals are done dynamically and
everything else is done statically.

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