Nested Scopes Question (exec)

Remco Gerlich scarblac at pino.selwerd.nl
Mon Jun 25 11:01:00 EDT 2001


Rainer Deyke <root at rainerdeyke.com> wrote in comp.lang.python:
> "Ryan LeCompte" <rmlecompte at hotmail.com> wrote in message
> news:mailman.993417398.9618.python-list at python.org...
> > P.S. --- Aren't the following two calls the same:
> >
> > exec "print 'hello'"
> > exec "print 'hello'" in globals(), locals()
> 
> No.  Modifying the dictionary returned from 'locals' does not change the
> bindings of local names.

Except when it does, of course (mainly outside of functions I believe, but
in general the result is undefined).

-- 
Remco Gerlich





More information about the Python-list mailing list