Nested Scopes Question (exec)

Rainer Deyke root at
Sun Jun 24 20:51:47 EDT 2001

"Tim Peters" < at> wrote in message
news:mailman.993425257.19425.python-list at
>     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
Shareware computer games           - 
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor

More information about the Python-list mailing list