Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #49073

Re: Is this PEP-able? fwhile

References <8D03F2B8CF0E7BE-1864-1796B@webmail-m103.sysops.aol.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2013-06-24 14:12 -0600
Subject Re: Is this PEP-able? fwhile
Newsgroups comp.lang.python
Message-ID <mailman.3760.1372104769.3114.python-list@python.org> (permalink)

Show all headers | View raw


On Mon, Jun 24, 2013 at 1:52 PM,  <jimjhb@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):
    ...

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Is this PEP-able? fwhile Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-24 14:12 -0600
  Re: Is this PEP-able? fwhile alex23 <wuwei23@gmail.com> - 2013-06-25 09:14 +1000
    Re: Is this PEP-able? fwhile Fábio Santos <fabiosantosart@gmail.com> - 2013-06-25 00:35 +0100
      Re: Is this PEP-able? fwhile alex23 <wuwei23@gmail.com> - 2013-06-25 10:00 +1000
        Re: Is this PEP-able? fwhile Fábio Santos <fabiosantosart@gmail.com> - 2013-06-25 01:19 +0100
        Re: Is this PEP-able? fwhile wu wei <wuwei23@gmail.com> - 2013-06-25 10:41 +1000
        Re: Is this PEP-able? fwhile Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-24 22:50 -0600
    Re: Is this PEP-able? fwhile rusi <rustompmody@gmail.com> - 2013-06-24 23:04 -0700

csiph-web