List comp bug?
tasjaevan at gmail.com
tasjaevan at gmail.com
Thu Apr 13 06:17:24 EDT 2006
I seem to have stumbled across a problem with list comprehensions (or
perhaps it's a misunderstanding on my part)
[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:
[f() for f in (lambda: t for t in ((1, 2), (3, 4)))]
is giving me
[(1, 2), (3, 4)]
as expected.
Is this a known bug? I'm using Python 2.4.3
Thanks
James
More information about the Python-list
mailing list