On 25 Jun 2013 00:31, "alex23" <wuwe...@gmail.com> wrote:
>
> On 25/06/2013 6:12 AM, Ian Kelly wrote:
>>
>> On Mon, Jun 24, 2013 at 1:52 PM,  <jim...@aol.com> wrote:
>>>
>>> Syntax:
>>> fwhile X in ListY and conditionZ:
>>>
>>> fwhile would act much like 'for', but would stop if the condition after
the
>>> 'and' is no longer True.
>>
>>
>> I would advocate using the break myself.  Another alternative is this:
>>
>> for X in itertools.takewhile(lambda X: conditionZ, ListY):
>>      ...
>
>
> 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.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to