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


Groups > comp.lang.python > #19219

Re: while True or while 1

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'subject:while': 0.07; 'python': 0.08; 'from:addr:python': 0.09; 'loop.': 0.09; 'output': 0.10; '"while': 0.16; '"with"': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16; 'habit.': 0.16; 'lines),': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'optimised': 0.16; 'received:84.92': 0.16; 'received:84.92.122': 0.16; 'received:84.92.122.60': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'reply-to:addr:python-list': 0.16; 'wrote:': 0.16; '2.2': 0.18; "they've": 0.18; 'jan': 0.19; '(which': 0.19; 'header:In-Reply-To:1': 0.22; 'literal': 0.23; 'string': 0.24; 'code': 0.25; 'suggestion': 0.25; '"the': 0.26; 'skip:p 30': 0.29; 'sun,': 0.30; "i've": 0.31; 'version': 0.31; 'break': 0.32; 'list': 0.32; 'header:User-Agent:1': 0.33; 'to:addr :python-list': 0.33; 'loop': 0.34; 'received:84': 0.34; 'too': 0.34; 'reply-to:addr:python.org': 0.34; 'statement,': 0.34; 'typical': 0.34; 'could': 0.37; 'steven': 0.38; 'mailing': 0.38; 'shows': 0.39; 'subject:: ': 0.39; 'to:addr:python.org': 0.40; 'believe': 0.65; 'lost': 0.68; 'soon': 0.71; 'header:Reply-To:1': 0.71; 'reply-to:no real name:2**0': 0.72; 'forever': 0.84; 'idiom': 0.84; 'sommers': 0.84; 'temperature': 0.93
X-CM-Score 0.00
X-CNFS-Analysis v=2.0 cv=J8QoHXbS c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=FFsdPcU1_MIA:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=AsXrbwpkmW1mXTH0a6IA:9 a=wPNLvfGTeEIA:10 a=0nF1XD0wxitMEM03M9B4ZQ==:117
X-AUTH mrabarnett:2500
Date Sun, 22 Jan 2012 16:13:37 +0000
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:9.0) Gecko/20111222 Thunderbird/9.0.1
MIME-Version 1.0
To python-list@python.org
Subject Re: while True or while 1
References <4F1AC1D4.2080402@gmail.com> <mailman.4909.1327157944.27778.python-list@python.org> <pL-dnUjq2eH3t4bSnZ2dnUVZ5vudnZ2d@giganews.com> <mailman.4914.1327184007.27778.python-list@python.org> <4f1b9dc4$0$29987$c3e8da3$5496439d@news.astraweb.com> <pan.2012.01.22.16.05.49@tombstonezero.net>
In-Reply-To <pan.2012.01.22.16.05.49@tombstonezero.net>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
Reply-To python-list@python.org
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.4927.1327248802.27778.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1327248802 news.xs4all.nl 6983 [2001:888:2000:d::a6]:60833
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:19219

Show key headers only | View raw


On 22/01/2012 16:05, Dan Sommers wrote:
> On Sun, 22 Jan 2012 05:25:25 +0000, Steven D'Aprano wrote:
>
>>  Or they've been writing Python code since before version 2.2 when True
>>  and False were introduced, and so they are used to the "while 1" idiom
>>  and never lost the habit.
>
> That would be me.
>
> As per a now-ancient suggestion on this mailing list (I believe it was by
> Tim Peters), I've also been known to use a non-empty, literal Python
> string as a self-documenting, forever-True value in the typical loop-and-a-
> half cnstruct:
>
>      while "the temperature is too big":
>          temperature = get_temperature()
>          if temperature<= threshold:
>              break
>          process_temperature(temperature)
>
> This way, even though the loop condition is buried inside the loop (which
> could be longer than four lines), it is apparent as soon as I encounter
> the loop.
>
And the output of "dis" shows that it's optimised to a forever loop.

> With the advent of the "with" statement, though, these loops are slowly
> disappearing.
>

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


Thread

Re: while True or while 1 Chris Angelico <rosuav@gmail.com> - 2012-01-22 01:59 +1100
  Re: while True or while 1 Erik Max Francis <max@alcyone.com> - 2012-01-21 13:13 -0800
    Re: while True or while 1 Chris Angelico <rosuav@gmail.com> - 2012-01-22 09:13 +1100
      Re: while True or while 1 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-01-22 05:25 +0000
        Re: while True or while 1 Dan Sommers <dan@tombstonezero.net> - 2012-01-22 16:05 +0000
          Re: while True or while 1 alex23 <wuwei23@gmail.com> - 2012-01-22 19:55 -0800
            Re: while True or while 1 Dave Angel <d@davea.name> - 2012-01-23 08:02 -0500
              Re: while True or while 1 Hrvoje Niksic <hniksic@xemacs.org> - 2012-01-23 14:28 +0100
                Re: while True or while 1 Dave Angel <d@davea.name> - 2012-01-23 13:33 -0500
        Re: while True or while 1 MRAB <python@mrabarnett.plus.com> - 2012-01-22 16:13 +0000
    Re: while True or while 1 Grant Edwards <invalid@invalid.invalid> - 2012-01-23 15:51 +0000
    Re: while True or while 1 Giampaolo Rodolà <g.rodola@gmail.com> - 2012-01-23 17:41 +0100
      Re: while True or while 1 Erik Max Francis <max@alcyone.com> - 2012-01-23 11:12 -0800
        Re: while True or while 1 Giampaolo Rodolà <g.rodola@gmail.com> - 2012-01-23 21:20 +0100
    Re: while True or while 1 Ian Kelly <ian.g.kelly@gmail.com> - 2012-01-23 10:39 -0700
    Re: while True or while 1 Evan Driscoll <edriscoll@wisc.edu> - 2012-01-23 12:05 -0600
    Re: while True or while 1 Andrea Crotti <andrea.crotti.0@gmail.com> - 2012-01-23 20:50 +0000
      Re: while True or while 1 88888 Dihedral <dihedral88888@googlemail.com> - 2012-01-23 14:42 -0800
      Re: while True or while 1 88888 Dihedral <dihedral88888@googlemail.com> - 2012-01-23 14:42 -0800
      Re: while True or while 1 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-01-24 03:37 +0000

csiph-web