[Python-3000] Is this a bug with list comprehensions or not?

Raymond Hettinger python at rcn.com
Thu Jul 10 23:26:15 CEST 2008


From: "Guido van Rossum" <guido at python.org>
> To be sure, IMO the generator expression is wrong in interpreting the
> StopIteration exception! It should fail the same way the list
> comprehension fails.

When exercising 2-to-3 on Zodb at the EuroPython sprints, we also found another oddity.  This code works in 2.6 but fails in 3.0 (it 
looks for the free variable in the global scope instead of the enclosing local scope):

class A(object):
    v = 8
    x = [v for i in range(6)]



Raymond





More information about the Python-3000 mailing list