Steven D'Aprano 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.


-- 
Steven

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to