Tom Machinski wrote:
In most cases, `list(generator)` works as expected. Thus,
`list(<generator expression>)` is generally equivalent to `[<generator
expression>]`.
Here's a minimal case where this equivalence breaks, causing a serious
and hard-to-detect bug in a program:
>>> def sit(): raise StopIteration()
StopIteration is intended to be used only within the .__next__ method of
iterators. The devs know that other 'off-label' use results in the
inconsistency you noted, but their and my view is 'don't do that'.
--
http://mail.python.org/mailman/listinfo/python-list