[Python-Dev] Re: *Simpler* string substitutions

Guido van Rossum guido@python.org
Thu, 11 Jul 2002 17:48:22 -0400


>     PM> 4. Access to variables is also problematic. Without
>     PM> compile-time support, access to nested scopes is impossible
>     PM> (AIUI).
> 
> Is this really true?  I think it was two IPC's ago that Jeremy and I
> discussed the possibility of adding a method to frame objects that
> would basically yield you the equivalent of globals+freevars+locals.

If f is a function and g is a function nested inside f, only those
locals of f that are also used in g get turned into cells.

So if f has a local variable x that isn't used by g (as far as the
compiler can see), there's no way for g to find f's value for x.
Remember that f may not be on g's call stack at all!

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