Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.063 X-Spam-Evidence: '*H*': 0.89; '*S*': 0.02; 'advocate': 0.07; 'indexing': 0.07; 'subject:PEP': 0.07; 'check,': 0.09; 'python': 0.11; "'break'": 0.16; "'for',": 0.16; '24,': 0.16; 'true:': 0.16; 'wrote:': 0.18; 'mon,': 0.24; 'this:': 0.26; 'header:In-Reply- To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'motivation': 0.31; 'another': 0.32; 'etc.)': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'aspects': 0.39; 'to:addr:python.org': 0.39; 'subject:? ': 0.60; 'break': 0.61; 'act': 0.63; 'great': 0.65; 'as:': 0.81; 'subject:this': 0.83; "'and'": 0.84; "'for'": 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=TN65jxhMswPYDKynmbwJ+M8y7BvwX8Iz2ypIT/aNMfY=; b=ijpByOfFDlbGe9SZUboLsrIs9LwPcfYEFLud/UbJubzIdrNByxgP2H1rKDWWKV7gYP MfiXAwm2xGNYZydaEsJ0iGY7UVM611oFQ+1QJ3oLOK5pNPDRu5EVXVGd6shrt4SzZtL+ vinAxUq+8Er6IgLKHC3TOZpt3Izxr+i1GL+HdVuV26sWCUWxrLD2CpqHc5kDnDXi+VU4 ByOSnX/SbQ6kE4CxrYfzidRttkaOv+OzJkWToB1dVce842eSDW6ZZmGQ1VpW998knqqo HE4xzU3w1r67YChBK8YsTbT+cQH6abaMdFGIvVj40pKkmUbgz6qM8xMU9abqNx3P2gYb Khdw== X-Received: by 10.68.189.199 with SMTP id gk7mr14417745pbc.208.1372104765159; Mon, 24 Jun 2013 13:12:45 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <8D03F2B8CF0E7BE-1864-1796B@webmail-m103.sysops.aol.com> References: <8D03F2B8CF0E7BE-1864-1796B@webmail-m103.sysops.aol.com> From: Ian Kelly Date: Mon, 24 Jun 2013 14:12:04 -0600 Subject: Re: Is this PEP-able? fwhile To: Python Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1372104769 news.xs4all.nl 15978 [2001:888:2000:d::a6]:33623 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:49073 On Mon, Jun 24, 2013 at 1:52 PM, 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): ...