Different behaviour in list comps and generator expressions

Ethan Furman ethan at stoneleaf.us
Mon Nov 17 21:20:00 EST 2014


On 11/17/2014 03:38 PM, Dan Stromberg wrote:
> 
> 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?

It's not the eagerness vs. laziness that's being changed, but rather what happens in a generator when something inside
the generator raises StopIteration (as opposed to the generator itself simply return'ing and thereby causing a
StopIteration to be generated).

--
~Ethan~

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20141117/3043d4f1/attachment.sig>


More information about the Python-list mailing list