[issue14972] listcomp with nested classes

2012-06-01 Thread Florent Xicluna
Florent Xicluna added the comment: This is a duplicate of issue 11796. See also issue 13557: http://bugs.python.org/issue13557#msg154174 For Python 3, a list comprehension defines a block pretty much like the method definition during the class creation: class x: x = 1 def incx():

[issue14972] listcomp with nested classes

2012-05-31 Thread Hynek Schlawack
Changes by Hynek Schlawack : -- nosy: +hynek ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python

[issue14972] listcomp with nested classes

2012-05-31 Thread R. David Murray
R. David Murray added the comment: This is doubtless a result of the way the class namespace scope is handled, coupled with the fact that in Python3 list comprehensions have a local scope. The class scope is a somewhat unique beast. I agree that this is unfortunate, but I have a feeling tha

[issue14972] listcomp with nested classes

2012-05-31 Thread Westley Martínez
Westley Martínez added the comment: $ python Python 3.2.3 (default, Apr 23 2012, 23:35:30) [GCC 4.7.0 20120414 (prerelease)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> class A: ... x = 42 ... y = [x for _ in '1'] ... Traceback (most recent call

[issue14972] listcomp with nested classes

2012-05-31 Thread Alex Gaynor
Changes by Alex Gaynor : -- nosy: +alex ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/

[issue14972] listcomp with nested classes

2012-05-31 Thread Florent Xicluna
Florent Xicluna added the comment: Simpler test case: class A: x = 42 y = [x for _ in '1'] The semantics of list comprehension changed with Python 3. However, I do not see this specific behavior documented somewhere. http://docs.python.org/dev/whatsnew/3.0.html#changed-syntax

[issue14972] listcomp with nested classes

2012-05-31 Thread josmiley
New submission from josmiley : # this runs with python2.7, not with python3.2 class Foo(object): class Bar(object): pass Attr = [Bar()for n in range(10)] # solved in this way ... class Foo(object): class Bar(object): pass Attr = [] for n in range(10): Attr