Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #49109
| References | <8D03F2B8CF0E7BE-1864-1796B@webmail-m103.sysops.aol.com> <mailman.3760.1372104769.3114.python-list@python.org> <kqajj8$54h$1@dont-email.me> |
|---|---|
| Date | 2013-06-25 00:35 +0100 |
| Subject | Re: Is this PEP-able? fwhile |
| From | Fábio Santos <fabiosantosart@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3788.1372116912.3114.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
On 25 Jun 2013 00:31, "alex23" <wuwei23@gmail.com> wrote: > > On 25/06/2013 6:12 AM, Ian Kelly wrote: >> >> On Mon, Jun 24, 2013 at 1:52 PM, <jimjhb@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.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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