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


Groups > comp.lang.python > #32069

Re: while expression feature proposal

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python.list@tim.thechases.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'pep': 0.09; 'subject:while': 0.09; 'cc:addr:python-list': 0.10; 'languages.': 0.15; '"with"': 0.16; '-tkc': 0.16; '24,': 0.16; 'assignment.': 0.16; 'expr': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'message-id:@tim.thechases.com': 0.16; 'oct': 0.16; 'received:70.251': 0.16; 'received:dsl.rcsntx.swbell.net': 0.16; 'received:rcsntx.swbell.net': 0.16; 'received:swbell.net': 0.16; 'statement.': 0.16; 'subject:expression': 0.16; 'true:': 0.16; 'ugly.': 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'duplicate': 0.17; 'variable': 0.20; 'bit': 0.21; 'cc:2**0': 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'skip:" 20': 0.26; "doesn't": 0.28; 'run': 0.28; 'dan': 0.29; 'this.': 0.29; "i'm": 0.29; 'could': 0.32; 'pm,': 0.35; 'really': 0.36; 'but': 0.36; 'being': 0.37; 'subject:: ': 0.38; 'sure': 0.38; 'most': 0.61; 'due': 0.66; 'felt': 0.75; 'idiomatic': 0.84; 'parity': 0.84; 'prey': 0.84; 'received:50.22': 0.84
Date Wed, 24 Oct 2012 16:54:32 -0500
From Tim Chase <python.list@tim.thechases.com>
User-Agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111120 Icedove/3.1.16
MIME-Version 1.0
To Ian Kelly <ian.g.kelly@gmail.com>
Subject Re: while expression feature proposal
References <CAOKWLrERVuT-u=9YZGnQUhWLv2M6F06pU20vG9W1joD9h-SdSQ@mail.gmail.com> <CALwzidm1zj5ZR4YU-DCWBgY3Q4m=UC0BNs3qJfwYpV+Kh+21cg@mail.gmail.com>
In-Reply-To <CALwzidm1zj5ZR4YU-DCWBgY3Q4m=UC0BNs3qJfwYpV+Kh+21cg@mail.gmail.com>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-AntiAbuse This header was added to track abuse, please include it with any abuse report
X-AntiAbuse Primary Hostname - boston.accountservergroup.com
X-AntiAbuse Original Domain - python.org
X-AntiAbuse Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse Sender Address Domain - tim.thechases.com
X-Source
X-Source-Args
X-Source-Dir
Cc Python <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.2798.1351115620.27098.python-list@python.org> (permalink)
Lines 36
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1351115620 news.xs4all.nl 6973 [2001:888:2000:d::a6]:54916
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:32069

Show key headers only | View raw


On 10/24/12 16:34, Ian Kelly wrote:
> On Wed, Oct 24, 2012 at 2:40 PM, Dan Loewenherz <dloewenherz@gmail.com> wrote:
>> So I'm sure a lot of you have run into the following pattern. I use it
>> all the time and it always has felt a bit awkward due to the duplicate
>> variable assignment.
>>
>> VAR = EXPR
>> while VAR:
>>     BLOCK
>>     VAR = EXPR
> 
> The idiomatic way to do this is:
> 
> while True:
>     VAR = EXPR
>     if not VAR:
>         break
>     BLOCK

It may be idiomatic, but that doesn't stop it from being pretty
ugly.  I must say I really like the parity of Dan's

  while EXPR as VAR:
     BLOCK

proposal with the "with" statement.  It also doesn't fall prey to
the "mistaken-assignment vs. intentional-assignment" found in most
C-like languages.  I could see a pretty reasonable PEP coming from this.

-tkc





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


Thread

Re: while expression feature proposal Tim Chase <python.list@tim.thechases.com> - 2012-10-24 16:54 -0500

csiph-web