On Mon, Jun 24, 2013 at 1:52 PM, <jim...@aol.com> wrote: > Syntax: > > fwhile X in ListY and conditionZ: > > The following would actually exactly as: for X in ListY: > > fwhile X in ListY and True: > > fwhile would act much like 'for', but would stop if the condition after the > 'and' is no longer True. > > The motivation is to be able to make use of all the great aspects of the > python 'for' (no indexing or explict > end condition check, etc.) and at the same time avoiding a 'break' from the > 'for'.
I would advocate using the break myself. Another alternative is this: for X in itertools.takewhile(lambda X: conditionZ, ListY): ... -- http://mail.python.org/mailman/listinfo/python-list