Author sandberg
Recipients sandberg
Date 2008-09-25.15:10:19
SpamBayes Score 1.11114e-08
Marked as misclassified No
Message-id <>
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).

x = 2
def f():
    exec "x = 1\ndef b(): return x"
    print b()

An unqualified guess is that the mix of being top-level and being a
local variable, makes the symbol end up somewhere between locals() and
globals(). Example:

The problem causes real-life problems when I want to create a wrapper
function around execfile() to handle certain exceptions.
Date User Action Args
2008-09-25 15:10:21sandbergsetrecipients: + sandberg
2008-09-25 15:10:21sandbergsetmessageid: <>
2008-09-25 15:10:20sandberglinkissue3963 messages
2008-09-25 15:10:19sandbergcreate