Is this PEP-able? fwhile

alex23 wuwei23 at gmail.com
Mon Jun 24 20:00:14 EDT 2013


On 25/06/2013 9:35 AM, Fábio Santos wrote:
>  > I'd probably just go with a generator expression to feed the for loop:
>  >
>  >     for X in (i for i in ListY if conditionZ):
>  >         ....
>
> That is nice but it's not lazy. If the condition or the iterables took
> too long to compute, it would be troublesome.

I'm not sure I follow. It's a generator expression, not a list 
comprehension, so the condition will be evaluated per item iterated over 
in the generator, not across all valid items in ListY at once.




More information about the Python-list mailing list