Message 72007 - Python tracker (original) (raw)

I believe the problem is that list comprehensions in 3.0 have scope like that of genexprs in 2.5, but the change was deliberate (as it also avoids leaking of temp variables).

Compare to 2.5:

class Foo(object): ... class_attribute1 = 1 ... class_attribute2 = (class_attribute1 for x in range(8)) ... Foo.class_attribute2.next() Traceback (most recent call last): File "", line 1, in File "", line 3, in NameError: global name 'class_attribute1' is not defined