Amaury Forgeot d'Arc added the comment: Facundo, are your sure that your output starts from a fresh environment? I get:
C:\Python25>python Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> class C: ... a = 42 ... list(a for _ in 'x') ... Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 3, in C File "<stdin>", line 3, in <genexpr> NameError: global name 'a' is not defined This error is actually approximately "documented" in an obscure sentence in http://docs.python.org/dev/reference/executionmodel.html#naming """ The scope of names defined in a class block is limited to the class block; it does not extend to the code blocks of methods. """ Well, I'm not sure that the genexpr can be considered as a "method", but it is certainly a nested code block. ---------- nosy: +amaury.forgeotdarc __________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue1863> __________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com