<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > [f() for f in [lambda: t for t in ((1, 2), (3, 4))]] > is giving me > [(3, 4), (3, 4)] > > The equivalent using a generator expression:
List comps were originally designed to be equivalent to for loops with nested for loops and if blocks. Generator expressions are know to be slightly different and *not* exactly equivalent due to the new local namespace. > [f() for f in (lambda: t for t in ((1, 2), (3, 4)))] > is giving me > [(1, 2), (3, 4)] Since, when there is a difference, as above, the genex behavior is more often the right or expected behavior (as above), Guido is considering making the diference go away in 3.0 by making [stuff] == list((stuff)) (ie, listcomp == list(genex)). Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list