Author sandberg
Recipients sandberg
Date 2008-09-25.15:10:19
SpamBayes Score 1.11114e-08
Marked as misclassified No
Message-id <1222355421.74.0.537715062608.issue3963@psf.upfronthosting.co.za>
In-reply-to
Content
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():
    exec "x = 1\ndef b(): return x"
    print b()
f()

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.
History
Date User Action Args
2008-09-25 15:10:21sandbergsetrecipients: + sandberg
2008-09-25 15:10:21sandbergsetmessageid: <1222355421.74.0.537715062608.issue3963@psf.upfronthosting.co.za>
2008-09-25 15:10:20sandberglinkissue3963 messages
2008-09-25 15:10:19sandbergcreate