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


Groups > comp.lang.python > #49144

Is this PEP-able? fwhile

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin1!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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.050
X-Spam-Evidence '*H*': 0.90; '*S*': 0.00; 'syntax': 0.04; 'guido': 0.05; 'explicit': 0.07; 'indexing': 0.07; 'subject:PEP': 0.07; "'no": 0.09; 'terminated': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'early.': 0.16; 'itertools': 0.16; 'elements': 0.16; 'so.': 0.16; 'separate': 0.22; 'cc:addr:python.org': 0.22; '(or': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '&gt;': 0.26; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'said,': 0.30; 'code': 0.31; 'ones.': 0.31; 'community': 0.33; 'maybe': 0.34; 'problem': 0.35; 'there': 0.35; 'largely': 0.36; 'charset:us-ascii': 0.36; 'list': 0.37; 'rather': 0.38; 'skip:u 10': 0.60; 'subject:? ': 0.60; 'from:no real name:2**0': 0.61; 'break': 0.61; 'new': 0.61; 'range': 0.61; 'header:Message-Id:1': 0.63; 'kind': 0.63; 'different': 0.65; 'benefit': 0.68; 'applying': 0.72; 'special': 0.74; 'subject:this': 0.83; "'for'": 0.84; "'while'": 0.84; 'received:172.29.51.203': 0.84; 'received :mtaomg-db05.r1000.mx.aol.com': 0.84; 'yours': 0.88; 'notion': 0.91
References <8D03F2B8CF0E7BE-1864-1796B@webmail-m103.sysops.aol.com> <CAN1F8qV1SvhpZO0DpBOqEoQ_quB4t0=LhZLc1i+XUkPnCvuiGw@mail.gmail.com>
To nhodgson@iinet.net.au
Subject Is this PEP-able? fwhile
In-Reply-To <CAN1F8qV1SvhpZO0DpBOqEoQ_quB4t0=LhZLc1i+XUkPnCvuiGw@mail.gmail.com>
X-MB-Message-Source WebUI
MIME-Version 1.0
From jimjhb@aol.com
X-MB-Message-Type User
Content-Type multipart/alternative; boundary="--------MB_8D03FACACF6D9FC_D84_73DC6_webmail-vm008.sysops.aol.com"
X-Mailer AOL Webmail 37834-STANDARD
X-Originating-IP [71.205.231.93]
Date Tue, 25 Jun 2013 07:17:12 -0400 (EDT)
x-aol-global-disposition G
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=mx.aol.com; s=20121107; t=1372159033; bh=eBKY1Yw/YRDOEo2NyRlvJHvuGDsMY+NsWeVfD1LAYOE=; h=From:To:Subject:Message-Id:Date:MIME-Version:Content-Type; b=nA4PTXeA9VEZqFZpbe5MPhgyzBSX77YlDz2hYYdBR1w7H93wrjGNtI7m9+zTSDQd7 4RRg5MK2QjJqxiJNOeQ9cg7rsU8Wz/AgbkoQkkaLPx7hz8ICrGV4f6ZJKt8Vr/F2q/ R+Kpn5bF1Qsjd2rtglEZOYvhXv+4vkmD394RBQcs=
X-AOL-SCOLL-SCORE 0:2:359804992:93952408
X-AOL-SCOLL-URL_COUNT 0
x-aol-sid 3039ac1d33cb51c97c3849e9
Cc python-list@python.org
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.3806.1372159042.3114.python-list@python.org> (permalink)
Lines 111
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1372159042 news.xs4all.nl 15886 [2001:888:2000:d::a6]:55361
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:49144

Show key headers only | View raw


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

> Syntax:
> fwhile X in ListY and conditionZ:

    There is precedent in Algol 68:

for i from 0 to n while safe(i) do .. od

    which would also make a python proposal that needs no new key words:

for i in range(n) while safe(i): ..

    The benefit of the syntax would be to concentrate the code 
expressing the domain of the loop rather than have it in separate locations.

    Not a big win in my opinion.

    Neil

Neil,

I disagree. The problem IMO is that python 'for's are a different kind of 'for' in that they have no explicit indexing and no explicit range test; just a list which has elements drawn from it.  This is amazingly 
powerful and concise.  Unfortunately, the "breaks are just gotos" community often ruins this conciseness by going to 'while' or itertools (or worse) to avoid adding a break to a 'for' which needs to be terminated early.

I think suggestions like yours and Fabio's are good ones.  If 'for' has an 'else', why not a 'while'?

FWIW, I can sympathize with the 'no breaks or continues' notion, at least largely so.  That said, I have used gotos sparingly in C.  The problem is that applying the no-breaks notion to the python 'for' is problematic because as I said earlier, the python 'for' is a special kind of 'for'.  Maybe Guido needs to be seen in public hugging a break statement.....  :)

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


Thread

Is this PEP-able? fwhile jimjhb@aol.com - 2013-06-25 07:17 -0400

csiph-web