Nested Scopes Question (exec)

Rainer Deyke root at rainerdeyke.com
Mon Jun 25 02:51:47 CEST 2001


"Tim Peters" <tim.one at home.com> wrote in message
news:mailman.993425257.19425.python-list at python.org...
>     Warning:  The contents of this dictionary should not be modified;
>     changes may not affect the values of local variables used by the
              ^^^^^^^
>     interpreter.

The wording here should probably be changed to "may or may not".  Otherwise
people might start to rely on the fact that dictionary usually doesn't
affect the local variables and do stuff like this:

def f(x):
  d = locals()
  d['x'] += 5
  exec 'print x' in d


--
Rainer Deyke (root at rainerdeyke.com)
Shareware computer games           -           http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor





More information about the Python-list mailing list