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


Groups > comp.lang.python > #49070

Is this PEP-able? fwhile

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <jimjhb@aol.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.093
X-Spam-Evidence '*H*': 0.82; '*S*': 0.00; '(at': 0.04; 'python)': 0.05; 'indexing': 0.07; 'subject:PEP': 0.07; 'welcome.': 0.07; 'check,': 0.09; 'python': 0.11; "'break'": 0.16; "'for',": 0.16; '(note:': 0.16; 'true:': 0.16; 'thanks.': 0.20; 'portion': 0.22; 'effort.': 0.24; "shouldn't": 0.24; 'least': 0.26; 'to:2**1': 0.27; 'to:no real name:2**1': 0.29; "doesn't": 0.30; "i'm": 0.30; 'code': 0.31; 'comments': 0.31; 'argue': 0.31; 'motivation': 0.31; 'themselves': 0.32; 'run': 0.32; 'sense': 0.34; 'could': 0.34; 'convert': 0.35; 'etc.)': 0.35; 'but': 0.35; 'much.': 0.36; 'charset:us-ascii': 0.36; 'possible': 0.36; 'too': 0.37; 'being': 0.38; 'to:addr:python-list': 0.38; 'aspects': 0.39; 'itself': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'from:no real name:2**0': 0.61; 'affect': 0.61; 'course': 0.61; 'making': 0.63; 'header:Message-Id:1': 0.63; 'act': 0.63; 'name': 0.63; 'teaching': 0.64; 'great': 0.65; 'to:addr:aol.com': 0.68; 'overall': 0.69; 'as:': 0.81; 'subject:this': 0.83; "'and'": 0.84; "'for'": 0.84; 'concept.': 0.84; 'received:64.12.224': 0.84; 'costs,': 0.91; 'taught': 0.96
To python-list@python.org, jimjhb@aol.com
Subject Is this PEP-able? fwhile
X-MB-Message-Source WebUI
X-MB-Message-Type User
MIME-Version 1.0
From jimjhb@aol.com
Content-Type multipart/alternative; boundary="--------MB_8D03F2B8CFA6D42_1864_56DC1_webmail-m103.sysops.aol.com"
X-Mailer AOL Webmail 37834-STANDARD
X-Originating-IP [208.67.228.35]
Date Mon, 24 Jun 2013 15:52:54 -0400 (EDT)
x-aol-global-disposition G
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=mx.aol.com; s=20121107; t=1372103575; bh=owbZ0NacWtoLApQRAJgxZh6Zqmnl5IWOCm77pmb7oe4=; h=From:To:Subject:Message-Id:Date:MIME-Version:Content-Type; b=Gw8SSyEV1hY2nqWEi4N+MK+e05FQzoh85ULTFyHOeaVeIbixk4CahR9A/J7F/a4xU ad0yKWTwrPk/669XRtqlIWArskUq9t1gXC0whxnzDjT/ZyH9cg19OIdxnuuHX68rxW 87B1hQXo/I9FNGqwN+udcrWffrpc61dsGCiYoS6E=
X-AOL-SCOLL-SCORE 0:2:313412960:93952408
X-AOL-SCOLL-URL_COUNT 0
x-aol-sid 3039ac1d294b51c8a3967f01
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3757.1372103911.3114.python-list@python.org> (permalink)
Lines 160
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1372103911 news.xs4all.nl 15989 [2001:888:2000:d::a6]:53176
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:49070

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

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'.  


(NOTE:  Many people are being taught to avoid 'break' and 'continue' at all costs, so they instead convert
the clean 'for' into a less-clean 'while'.  Or they just let the 'for' run out.  You can argue against this teaching
(at least for Python) but that doesn't mean it's not prevalent and prevailing.)


[People who avoid the 'break' by functionalizing an inner portion of the loop are just kidding themselves and making
their own code worse, IMO.]


I'm not super familiar with CPython, but I'm pretty sure I could get this up and working without too much effort.
The mandatory 'and' makes sense because 'or' would hold the end value valid (weird) and not accomplish much.
The condition itself could of course have multiple parts to it, including 'or's.


It's possible the name 'fwhile' is not optimal, but that shouldn't affect the overall merit/non-merit of the concept.


Comments and Questions welcome.


Thanks.  

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


Thread

Is this PEP-able?   fwhile jimjhb@aol.com - 2013-06-24 15:52 -0400
  Re: Is this PEP-able?   fwhile Neil Hodgson <nhodgson@iinet.net.au> - 2013-06-25 17:20 +1000
    Re: Is this PEP-able?   fwhile Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-06-25 20:47 -0400
    Re: Is this PEP-able? fwhile Chris Angelico <rosuav@gmail.com> - 2013-06-26 17:40 +1000

csiph-web