Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Klein bottle for rent -- inquire within.


devel / comp.lang.python / Re: Friday Finking: Contorted loops

SubjectAuthor
o Re: Friday Finking: Contorted loopsTerry Reedy

1
Re: Friday Finking: Contorted loops

<mailman.692.1631336799.4164.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=15106&group=comp.lang.python#15106

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: tjre...@udel.edu (Terry Reedy)
Newsgroups: comp.lang.python
Subject: Re: Friday Finking: Contorted loops
Date: Fri, 10 Sep 2021 21:30:32 -0400
Lines: 35
Message-ID: <mailman.692.1631336799.4164.python-list@python.org>
References: <097bf31d-44e8-da35-df41-3834524716c9@DancesWithMice.info>
<shfg3i$4e6$1@ciao.gmane.io> <shh0rt$13ah$1@ciao.gmane.io>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de TBcM2lcqep2z6qT30hCZFAvxbRwIn+ES+Gs36aihrvzw==
Return-Path: <python-python-list@m.gmane-mx.org>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.003
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'loop': 0.07; 'loops.':
0.07; 'message-id:@ciao.gmane.io': 0.09; 'received:ciao.gmane.io':
0.09; 'received:gmane.io': 0.09; 'received:list': 0.09; 'terry':
0.09; 'complete.': 0.16; 'doc': 0.16; 'effects.': 0.16; 'false.':
0.16; 'from:addr:udel.edu': 0.16; 'gauld': 0.16; 'goto': 0.16;
'if...else': 0.16; 'part.': 0.16; 'received:116.202': 0.16;
'received:116.202.254': 0.16; 'received:116.202.254.214': 0.16;
'syntactic': 0.16; 'wrote:': 0.16; 'python': 0.16; 'to:addr
:python-list': 0.20; 'maybe': 0.22; 'else': 0.27; 'header:User-
Agent:1': 0.30; 'am,': 0.31; 'looked': 0.31; 'python-list': 0.32;
'but': 0.32; 'header:In-Reply-To:1': 0.34; 'could': 0.38; 'read':
0.38; 'adding': 0.39; 'still': 0.40; 'alan': 0.40; 'received:116':
0.64; 'body': 0.67; 'exactly': 0.68; 'further': 0.69; 'more.':
0.82; 'clause': 0.84; 'improved.': 0.84; 'opposite': 0.91;
'viewed': 0.93
X-Injected-Via-Gmane: http://gmane.org/
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
In-Reply-To: <shfg3i$4e6$1@ciao.gmane.io>
Content-Language: en-US
X-Mailman-Approved-At: Sat, 11 Sep 2021 01:06:39 -0400
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
Precedence: list
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: <https://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>
X-Mailman-Original-Message-ID: <shh0rt$13ah$1@ciao.gmane.io>
X-Mailman-Original-References: <097bf31d-44e8-da35-df41-3834524716c9@DancesWithMice.info>
<shfg3i$4e6$1@ciao.gmane.io>
 by: Terry Reedy - Sat, 11 Sep 2021 01:30 UTC

On 9/10/2021 7:38 AM, Alan Gauld via Python-list wrote:

> But python complicates this tenet still further by adding an else
> clause to its loops. And complicating this still more is that these
> else clauses have almost exactly opposite effects.

To the contrary...

if...else
executes the else part if the condition is false.

>
> while...else...
>
> executes the else if the body of the loop does NOT get executed.

IE, executes the else part if the condition is false.
A while statement is, or can be viewed as, an if statement with a goto
ending the if part.

> for...else...
>
> executes the else iff ALL iterations of the for loop DO complete.

IE, executes the else part of the condition is false.
A for loop is, or can be viewed as syntactic sugar for a while loop.
The condition is that next(iterable) yields a value.

It is possible that the doc could be improved. I have not looked for a
while. Or maybe it needs to be read more.

--
Terry Jan Reedy

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor