This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jhylton
Recipients
Date 2006-04-03.15:44:35
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Logged In: YES 
user_id=31392

The source of the problem is that scoping decisions are made
statically.  If a variable is determined to be local at
compile time, it can't be access as a free variable in
dynamically compiled code.  The compiler has already
determined that the variable is *not* free in the containing
function.  If a variable is free in a nested function, the
compiler treats it differently than if it is merely local to
the function.

In the most recent cases considered,
def f(x): eval('x') -- works because x is a local variable in f.
def f(g): eval('lambda x: g(x)') -- does not work because
the compiler has determined that g is not used a free
variable in f.  It isn't possible to change that static
analysis at runtime using eval or exec.

I agree that the documentation could be clearer here.
History
Date User Action Args
2007-08-23 14:29:50adminlinkissue1153622 messages
2007-08-23 14:29:50admincreate