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


Groups > comp.lang.python > #82408

RE: Extension of while syntax

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <crk@godblessthe.us>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.049
X-Spam-Evidence '*H*': 0.90; '*S*': 0.00; 'skip:[ 20': 0.04; 'syntax': 0.04; 'skip:> 40': 0.09; 'subject:while': 0.09; 'clayton': 0.16; 'email addr:python.org]': 0.16; 'finney': 0.16; 'repetition,': 0.16; 'true:': 0.16; 'zero,': 0.16; 'thursday,': 0.16; 'bit': 0.19; 'message-----': 0.19; 'thoughts': 0.19; 'seems': 0.21; 'this?': 0.23; 'url:moin': 0.24; "i've": 0.25; 'extension': 0.26; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; 'generally': 0.29; 'url:mailman': 0.30; 'url:wiki': 0.31; 'writes:': 0.31; 'url:python': 0.33; 'common': 0.35; 'december': 0.35; 'skip:s 30': 0.35; 'something': 0.35; 'there': 0.35; 'skip:> 10': 0.36; 'url:listinfo': 0.36; 'url:org': 0.36; 'email addr:python.org': 0.37; 'ben': 0.38; 'to:addr:python-list': 0.38; 'that,': 0.38; 'use.': 0.39; 'to:addr:python.org': 0.39; 'url:mail': 0.40; 'skip:u 10': 0.60; 'break': 0.61; 'url:3': 0.61; 'received:173': 0.61; 're:': 0.63; 'email name:python-list': 0.65; 'received:phx3.secureserver.net': 0.65; 'received:prod.phx3.secureserver.net': 0.65; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'empire': 0.84; 'subject:Extension': 0.84; 'received:173.201': 0.91; 'received:173.201.192': 0.91
From "Clayton Kirkwood" <crk@godblessthe.us>
To "'Ben Finney'" <ben+python@benfinney.id.au>, <python-list@python.org>
References <14d2b880-3837-4267-a769-33ae7393f78b@googlegroups.com> <857fxxfv9u.fsf@benfinney.id.au>
In-Reply-To <857fxxfv9u.fsf@benfinney.id.au>
Subject RE: Extension of while syntax
Date Thu, 11 Dec 2014 18:59:20 -0800
MIME-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding quoted-printable
X-Mailer Microsoft Office Outlook 12.0
thread-index AdAVtL6ca9oFt+FLSZenBFxlerQHVgAAktoA
Content-Language en-us
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To crk@godblessthe.us
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.16888.1418353190.18130.python-list@python.org> (permalink)
Lines 60
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1418353190 news.xs4all.nl 2903 [2001:888:2000:d::a6]:38090
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:82408

Show key headers only | View raw


I would prefer:
while value = initial_value in undesired_values:
        value = get_some_value()

Seems I've seen something like this before, C, Perl?

Clayton


>-----Original Message-----
>From: Python-list [mailto:python-list-
>bounces+crk=godblessthe.us@python.org] On Behalf Of Ben Finney
>Sent: Thursday, December 11, 2014 6:38 PM
>To: python-list@python.org
>Subject: Re: Extension of while syntax
>
>Nelson Crosby <nc@sourcecomb.com> writes:
>
>> I was thinking a bit about the following pattern:
>>
>> value = get_some_value()
>> while value in undesired_values:
>>     value = get_some_value()
>
>I think that's an anti-pattern (because of the repetition, as you say).
>
>An improvement::
>
>    value = some_default_value_such_as_None
>    while value in undesired_values:
>        value = get_some_value()
>
>More common and generally useful::
>
>    while True:
>        value = get_some_value()
>        if value not in undesired_values:
>            break
>
>> What are other's thoughts on this?
>
>I think there are already clean ways to deal with this in common use.
>
><URL:https://wiki.python.org/moin/WhileLoop>
><URL:https://docs.python.org/3/tutorial/controlflow.html#break-and-
>continue-statements-and-else-clauses-on-loops>
>
>--
> \       “… one of the main causes of the fall of the Roman Empire was |
>  `\        that, lacking zero, they had no way to indicate successful |
>_o__)                  termination of their C programs.” —Robert Firth |
>Ben Finney
>
>--
>https://mail.python.org/mailman/listinfo/python-list

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


Thread

Extension of while syntax Nelson Crosby <nc@sourcecomb.com> - 2014-12-11 18:21 -0800
  Re: Extension of while syntax Ben Finney <ben+python@benfinney.id.au> - 2014-12-12 13:37 +1100
  Re: Extension of while syntax Chris Angelico <rosuav@gmail.com> - 2014-12-12 13:38 +1100
    Re: Extension of while syntax Marko Rauhamaa <marko@pacujo.net> - 2014-12-12 09:10 +0200
      Re: Extension of while syntax Chris Angelico <rosuav@gmail.com> - 2014-12-12 18:38 +1100
        Re: Extension of while syntax Marko Rauhamaa <marko@pacujo.net> - 2014-12-12 10:25 +0200
      Re: Extension of while syntax cl@isbd.net - 2014-12-12 09:09 +0000
        Re: Extension of while syntax Marko Rauhamaa <marko@pacujo.net> - 2014-12-12 12:33 +0200
  RE: Extension of while syntax "Clayton Kirkwood" <crk@godblessthe.us> - 2014-12-11 18:59 -0800
  Re: Extension of while syntax Terry Reedy <tjreedy@udel.edu> - 2014-12-11 22:00 -0500
  Re: Extension of while syntax Ben Finney <ben+python@benfinney.id.au> - 2014-12-12 14:14 +1100
  Re: Extension of while syntax Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-12-12 08:00 +0000
  Re: Extension of while syntax Chris Angelico <rosuav@gmail.com> - 2014-12-12 19:05 +1100
  Re: Extension of while syntax Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-12-12 11:38 -0500
  Re: Extension of while syntax Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-12-13 22:56 +1100

csiph-web