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.

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

Reply via email to