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


Groups > comp.lang.python > #32068 > unrolled thread

Re: while expression feature proposal

Started byIan Kelly <ian.g.kelly@gmail.com>
First post2012-10-24 15:34 -0600
Last post2012-10-24 15:34 -0600
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: while expression feature proposal Ian Kelly <ian.g.kelly@gmail.com> - 2012-10-24 15:34 -0600

#32068 — Re: while expression feature proposal

FromIan Kelly <ian.g.kelly@gmail.com>
Date2012-10-24 15:34 -0600
SubjectRe: while expression feature proposal
Message-ID<mailman.2797.1351114478.27098.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web