On 23.03.2016 22:44, Michael Selik
wrote:
They read well, except for the square brackets which to me
imply consuming the entire iterator. Itertools takewhile will
early exit, possibly leaving some values on the iterator. If
these do consume the entire iterator, what's the difference with
the ``if`` clause in a comprehension?
But isn't that their purpose? Not consuming. I think that would be
easy to learn. +1 on this proposal.
This could also prove useful to avoid for-else. :-)
After the execution of the list comprehension using "while" if the condition triggered halfway, would there be anything left in the original iterator? If it was a generator expression, we'd say "Yes" immediately. As a list comprehension, I'm not sure.