On Mon, Nov 17, 2014 at 3:30 PM, Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> wrote: >> The following list comprehension and generator expression are almost, but >> not quite, the same: >> >> [expr for x in iterable] >> >> list(expr for x in iterable) >> >> >> The difference is in the handling of StopIteration raised inside the expr. > [...] > > > Thanks to Roy and Wolfgang for their comments. > > If anyone is interested, Guido will soon be ruling on a PEP which will > change the behaviour of generators and generator expressions, and he has > asked for feedback. In particular, examples of code which will be broken by > this change. > > Read the PEP here: > > https://www.python.org/dev/peps/pep-0479 > > > If you post comments here, I will see that they get forwarded on.
I'm inclined to say that list comprehensions and generator expressions should be different. I don't really think they should be identical, one being eager and one being lazy. Why let the implementation detail of one impact the other? -- https://mail.python.org/mailman/listinfo/python-list