(Note also that functions which use exec cannot use the static namespace optimization, and thus tend to be *much* slower than normal functions (in addition to being a huge security problem). I don't know, however, whether locals() can update the local namespace in such un-optimized functions.
Doesn't look like it:
>>> exec """\ ... def f(): ... x = 3 ... locals()['x'] = 4 ... print x ... """ >>> f() 3
Steve -- http://mail.python.org/mailman/listinfo/python-list