[issue1863] NameError with genexp in class scope

2008-01-18 Thread Georg Brandl
Georg Brandl added the comment: Amaury Forgeot d'Arc schrieb: > Well, I'm not sure that the genexpr can be considered as a "method", but > it is certainly a nested code block. Technically it is a method, that's why this happens. I added a note to the docs in r60051; closing this as "won't fix".

[issue1863] NameError with genexp in class scope

2008-01-18 Thread Facundo Batista
Facundo Batista added the comment: Yes, something was bad with my test. Now I have the same behaviour. Sorry for the noise. __ Tracker <[EMAIL PROTECTED]> __ __

[issue1863] NameError with genexp in class scope

2008-01-18 Thread Amaury Forgeot d'Arc
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.

[issue1863] NameError with genexp in class scope

2008-01-18 Thread Facundo Batista
Facundo Batista added the comment: Don't follow you: >>> class C: a = 42 list(a for _ in 'x') >>> Works here! (Python 2.5.1 on win32) -- nosy: +facundobatista __ Tracker <[EMAIL PROTECTED]> __

[issue1863] NameError with genexp in class scope

2008-01-17 Thread Raymond Hettinger
Raymond Hettinger added the comment: I don't follow what you mean. Can you post a working version of the code fragment? -- nosy: +rhettinger __ Tracker <[EMAIL PROTECTED]> __

[issue1863] NameError with genexp in class scope

2008-01-17 Thread Guido van Rossum
Guido van Rossum added the comment: It's a weakness, not a bug. Just use a different variable name besides 'a'. -- nosy: +gvanrossum __ Tracker <[EMAIL PROTECTED]> __

[issue1863] NameError with genexp in class scope

2008-01-17 Thread Willard
New submission from Willard: The following code does not work like expected, it triggers a NameError. class C: a = 42 list(a for _ in 'x') >>> NameError: global name 'a' is not defined This issue was discussed on comp.lang.python in the thread "Is this a bug, or is it me?". -