Using import in an exec'ed string

Steve Holden sholden at holdenweb.com
Mon Aug 6 14:15:41 CEST 2001


Bernhard Herzog" <bh at intevation.de> wrote in message
news:6q4rrlsck9.fsf at abnoba.intevation.de...
[ ... ]
>
> It seems to me that with nested scopes f should be able to access the
> surrounding scope's names.
>
Indeed it should, but remember that these scopes are STATIC (i.e. determined
at compile time) and not dynamic ("I'll just have a look in my caller's
local namespace to see whether what I want is there").

Thus by the time you call f, the compiler has already determined which names
are from nested scopes, by looking at functions whose definition surrounds
the definition of f. If there aren't any, no nested scopes.

regards
 STeve
--
http://www.holdenweb.com/








More information about the Python-list mailing list