[issue3963] Problems when calling exec from a function

2008-09-25 Thread Erik Sandberg
Erik Sandberg <[EMAIL PROTECTED]> added the comment: Thanks! Passing an explicit global namespace solves the problem and is something I wanted to do anyways, when I think about it. ___ Python tracker <[EMAIL PROTECTED]> _

[issue3963] Problems when calling exec from a function

2008-09-25 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc <[EMAIL PROTECTED]> added the comment: See also: http://docs.python.org/dev/reference/executionmodel.html#interaction- with-dynamic-features ___ Python tracker <[EMAIL PROTECTED]> ___

[issue3963] Problems when calling exec from a function

2008-09-25 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc <[EMAIL PROTECTED]> added the comment: Right. Nested scopes only work for statically compiled code; inside an 'exec' block, non-local variables are global. In your case, I suggest to specify the context in which the code has to execute: x = 2 def f(): g = globals().copy

[issue3963] Problems when calling exec from a function

2008-09-25 Thread Erik Sandberg
New submission from Erik Sandberg <[EMAIL PROTECTED]>: When an exec statement called from a function f defines a top-level function g, the body of g cannot access the top-level symbols defined by the exec statement (which also happen to be the local variables of f). Example: x = 2 def f(): e