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.

classification
Title: name not found in generator in eval()
Type: behavior Stage:
Components: Interpreter Core Versions: Python 2.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder: eval does not bind variables in lambda bodies correctly
View: 1153622
Assigned To: Nosy List: LambertDW, amaury.forgeotdarc, fjhpy
Priority: normal Keywords:

Created on 2009-01-24 18:49 by fjhpy, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg80469 - (view) Author: Frank Henigman (fjhpy) Date: 2009-01-24 18:49
# works
>>> eval( "sum( [ a[0]=='a' for j in 'a' ] )", {}, dict(a='a'))
# take out the square brackets
>>> eval( "sum(   a[0]=='a' for j in 'a'   )", {}, dict(a='a'))
NameError: global name 'a' is not defined
msg82279 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-02-16 22:58
This is a duplicate of issue1153622.
a generator expression is actually a separate piece of compiled code, 
like a lambda expression.
History
Date User Action Args
2022-04-11 14:56:44adminsetgithub: 49294
2009-02-16 22:58:39amaury.forgeotdarcsetstatus: open -> closed
resolution: duplicate
superseder: eval does not bind variables in lambda bodies correctly
messages: + msg82279
nosy: + amaury.forgeotdarc
2009-01-24 20:17:33LambertDWsetnosy: + LambertDW
2009-01-24 18:49:06fjhpycreate