Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

All extremists should be taken out and shot.


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

SubjectAuthor
* Re: Friday Finking: Contorted loopsAlan Gauld
`* Re: Friday Finking: Contorted loopsStefan Ram
 +- Re: Friday Finking: Contorted loopsAlan Gauld
 +* RE: Friday Finking: Contorted loopsAvi Gross
 |`* Re: Friday Finking: Contorted loopsjak
 | `* Re: Friday Finking: Contorted loopsjak
 |  +- Re: Friday Finking: Contorted loopsalister
 |  `- Re: Friday Finking: Contorted loopsAlan Gauld
 `* Re: Friday Finking: Contorted loopsJoe Pfeiffer
  `- Re: Friday Finking: Contorted loopsPaul Rubin

1
Re: Friday Finking: Contorted loops

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: alan.gauld@yahoo.co.uk (Alan Gauld)
Newsgroups: comp.lang.python
Subject: Re: Friday Finking: Contorted loops
Date: Fri, 10 Sep 2021 16:57:39 +0100
Lines: 29
Message-ID: <mailman.686.1631298676.4164.python-list@python.org>
References: <097bf31d-44e8-da35-df41-3834524716c9@DancesWithMice.info>
<shfg3i$4e6$1@ciao.gmane.io>
<05c4abc0-70b6-b2ea-7cfa-1121d75d2126@mrabarnett.plus.com>
<shfv9j$dii$1@ciao.gmane.io>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de NbWSuRtMt1UU6fTUwS6rFggZJX4nfmkw8V43tZiTF1cw==
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.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'beginners': 0.05; 'url-
ip:65/8': 0.05; 'loop': 0.07; 'message-id:@ciao.gmane.io': 0.09;
'ok,': 0.09; 'perspective': 0.09; 'received:ciao.gmane.io': 0.09;
'received:gmane.io': 0.09; 'received:list': 0.09; '[snip]': 0.16;
'cases,': 0.16; 'complete.': 0.16; 'confusion': 0.16; 'flickr':
0.16; 'from:addr:alan.gauld': 0.16; 'from:name:alan gauld': 0.16;
'photo-blog': 0.16; 'received:116.202': 0.16;
'received:116.202.254': 0.16; 'received:116.202.254.214': 0.16;
'url-ip:79.170.44.132/32': 0.16; 'url-ip:79.170.44/24': 0.16;
'url-ip:79.170/16': 0.16; 'url-ip:79/8': 0.16; 'url:alan-g': 0.16;
'url:alan_gauld': 0.16; 'url:alangauldphotos': 0.16; 'wrote:':
0.16; 'url:amazon': 0.20; 'to:addr:python-list': 0.23; 'else':
0.27; "didn't": 0.29; 'header:User-Agent:1': 0.31; 'program':
0.33; 'header:In-Reply-To:1': 0.33; 'at:': 0.37; "that's": 0.37;
'author': 0.38; "it's": 0.38; 'use': 0.38; 'does': 0.38; 'least':
0.40; 'skip:w 10': 0.61; 'body': 0.63; 'follow': 0.63; 'site':
0.69; 'url:author': 0.69; 'received:116': 0.71
X-Injected-Via-Gmane: http://gmane.org/
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
In-Reply-To: <05c4abc0-70b6-b2ea-7cfa-1121d75d2126@mrabarnett.plus.com>
Content-Language: en-GB
X-Mailman-Approved-At: Fri, 10 Sep 2021 14:31:14 -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: <shfv9j$dii$1@ciao.gmane.io>
X-Mailman-Original-References: <097bf31d-44e8-da35-df41-3834524716c9@DancesWithMice.info>
<shfg3i$4e6$1@ciao.gmane.io>
<05c4abc0-70b6-b2ea-7cfa-1121d75d2126@mrabarnett.plus.com>
 by: Alan Gauld - Fri, 10 Sep 2021 15:57 UTC

On 10/09/2021 16:36, MRAB wrote:

>> while...else...
>>
>> executes the else if the body of the loop does NOT get executed.
>>
>> for...else...
>>
>> executes the else iff ALL iterations of the for loop DO complete.
>>
> [snip]
>
> In both cases, it executes the 'else' part if it didn't break out of the
> loop. That's it.

OK, That's a useful perspective that is at least consistent.

Unfortunately it's not how beginners perceive it and it causes
regular confusion about how/when they should use else with a loop.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos

Re: Friday Finking: Contorted loops

<Beginners-20210910194859@ram.dialup.fu-berlin.de>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: Friday Finking: Contorted loops
Date: 10 Sep 2021 18:49:50 GMT
Organization: Stefan Ram
Lines: 9
Expires: 1 Dec 2021 11:59:58 GMT
Message-ID: <Beginners-20210910194859@ram.dialup.fu-berlin.de>
References: <097bf31d-44e8-da35-df41-3834524716c9@DancesWithMice.info> <shfg3i$4e6$1@ciao.gmane.io> <05c4abc0-70b6-b2ea-7cfa-1121d75d2126@mrabarnett.plus.com> <shfv9j$dii$1@ciao.gmane.io> <mailman.686.1631298676.4164.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de sd3hn/Rr1ypEtrP78AVX5w3fDibkaA5z+YRMt8uG2blyLv
X-Copyright: (C) Copyright 2021 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Fri, 10 Sep 2021 18:49 UTC

Alan Gauld <alan.gauld@yahoo.co.uk> writes:
>OK, That's a useful perspective that is at least consistent.
>Unfortunately it's not how beginners perceive it
....

Beginners perceive it the way it is explained to them by
their teacher.

Re: Friday Finking: Contorted loops

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: alan.gauld@yahoo.co.uk (Alan Gauld)
Newsgroups: comp.lang.python
Subject: Re: Friday Finking: Contorted loops
Date: Sat, 11 Sep 2021 08:58:58 +0100
Lines: 29
Message-ID: <mailman.702.1631375618.4164.python-list@python.org>
References: <097bf31d-44e8-da35-df41-3834524716c9@DancesWithMice.info>
<shfg3i$4e6$1@ciao.gmane.io>
<05c4abc0-70b6-b2ea-7cfa-1121d75d2126@mrabarnett.plus.com>
<shfv9j$dii$1@ciao.gmane.io>
<mailman.686.1631298676.4164.python-list@python.org>
<Beginners-20210910194859@ram.dialup.fu-berlin.de>
<shhnk5$bvr$1@ciao.gmane.io>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de vJXxd4uE4NWptLplOqIgMwbOom3BjxOUGyl9Dqjg/rMw==
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.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'beginners': 0.05; 'loop':
0.07; 'ram': 0.07; 'message-id:@ciao.gmane.io': 0.09; 'ok,': 0.09;
'perspective': 0.09; 'received:ciao.gmane.io': 0.09;
'received:gmane.io': 0.09; 'received:list': 0.09; 'teachers':
0.09; 'writes:': 0.09; 'syntax': 0.15; 'beginners,': 0.16;
'flickr': 0.16; 'for.': 0.16; 'from:addr:alan.gauld': 0.16;
'from:name:alan gauld': 0.16; 'gauld': 0.16; 'photo-blog': 0.16;
'received:116.202': 0.16; 'received:116.202.254': 0.16;
'received:116.202.254.214': 0.16; 'url-ip:79.170.44.132/32': 0.16;
'url-ip:79.170.44/24': 0.16; 'url-ip:79.170/16': 0.16; 'url-
ip:79/8': 0.16; 'url:alan-g': 0.16; 'url:alan_gauld': 0.16;
'url:alangauldphotos': 0.16; 'wrote:': 0.16; 'python': 0.16;
'url:amazon': 0.19; 'to:addr:python-list': 0.20; 'stefan': 0.26;
'url-ip:104.85.6.101/32': 0.26; 'url-ip:104.85.6/24': 0.26;
'header:User-Agent:1': 0.30; 'program': 0.31; 'think': 0.32;
'everyone': 0.32; 'happening': 0.32; 'but': 0.32; "i'm": 0.33;
'header:In-Reply-To:1': 0.34; "it's": 0.37; 'author': 0.37;
'students': 0.38; 'way': 0.38; 'least': 0.39; 'alan': 0.40;
'true.': 0.40; 'learn': 0.40; 'best': 0.61; 'point.': 0.62;
'follow': 0.62; 'our': 0.64; 'explained': 0.64; 'received:116':
0.64; 'url-ip:13.249/16': 0.68; 'right': 0.68; 'url:author': 0.69;
'site': 0.70; 'experience.': 0.70; 'url-ip:13.249.48/24': 0.81;
'inconsistent': 0.84
X-Injected-Via-Gmane: http://gmane.org/
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
In-Reply-To: <Beginners-20210910194859@ram.dialup.fu-berlin.de>
Content-Language: en-GB
X-Mailman-Approved-At: Sat, 11 Sep 2021 11:53:37 -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: <shhnk5$bvr$1@ciao.gmane.io>
X-Mailman-Original-References: <097bf31d-44e8-da35-df41-3834524716c9@DancesWithMice.info>
<shfg3i$4e6$1@ciao.gmane.io>
<05c4abc0-70b6-b2ea-7cfa-1121d75d2126@mrabarnett.plus.com>
<shfv9j$dii$1@ciao.gmane.io>
<mailman.686.1631298676.4164.python-list@python.org>
<Beginners-20210910194859@ram.dialup.fu-berlin.de>
 by: Alan Gauld - Sat, 11 Sep 2021 07:58 UTC

On 10/09/2021 19:49, Stefan Ram wrote:
> Alan Gauld <alan.gauld@yahoo.co.uk> writes:
>> OK, That's a useful perspective that is at least consistent.
>> Unfortunately it's not how beginners perceive it
> ...
>
> Beginners perceive it the way it is explained to them by
> their teacher.

I'm not sure that's true. Most beginners, in my experience,
learn the syntax from their teachers and then go off and play.
What they observe happening is what sticks. And python loop
'else' constructs appear inconsistent to them.

As teachers we like to think we are passing on our wisdom
to our students but in reality everyone learns from their
own experience. The teachers advice is just the starting
point. Hopefully, that starting point sends them in the
right direction but that's the best we can hope for.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos

RE: Friday Finking: Contorted loops

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: avigross@verizon.net (Avi Gross)
Newsgroups: comp.lang.python
Subject: RE: Friday Finking: Contorted loops
Date: Sat, 11 Sep 2021 16:29:36 -0400
Lines: 152
Message-ID: <mailman.705.1631392181.4164.python-list@python.org>
References: <097bf31d-44e8-da35-df41-3834524716c9@DancesWithMice.info>
<shfg3i$4e6$1@ciao.gmane.io>
<05c4abc0-70b6-b2ea-7cfa-1121d75d2126@mrabarnett.plus.com>
<shfv9j$dii$1@ciao.gmane.io>
<mailman.686.1631298676.4164.python-list@python.org>
<Beginners-20210910194859@ram.dialup.fu-berlin.de>
<shhnk5$bvr$1@ciao.gmane.io>
<041f01d7a74b$bd3d83b0$37b88b10$@verizon.net>
Mime-Version: 1.0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de m0rFheAiNwdJ0kE6NRn19AOxK99inNbewbfbylVvvgEQ==
Return-Path: <avigross@verizon.net>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=verizon.net header.i=@verizon.net header.b=Y1G6XZW8;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'this:': 0.03; 'beginners':
0.05; 'row': 0.05; 'run.': 0.05; 'variable': 0.05; 'else.': 0.07;
'exit': 0.07; 'loop': 0.07; 'ram': 0.07; 'tests': 0.07; 'van':
0.07; 'characters,': 0.09; 'construct': 0.09; 'constructs,': 0.09;
'effectively': 0.09; 'numeric': 0.09; 'ok,': 0.09; 'other.': 0.09;
'perspective': 0.09; 'teachers': 0.09; 'treated': 0.09; 'way?':
0.09; 'writes:': 0.09; 'url:mailman': 0.15; 'syntax': 0.15; 'bag':
0.16; 'beginners,': 0.16; 'confusion.': 0.16; 'construct.': 0.16;
'continue.': 0.16; 'else?': 0.16; 'evaluating': 0.16; 'false.':
0.16; 'flickr': 0.16; 'for.': 0.16; 'gauld': 0.16; 'humans': 0.16;
'invoke': 0.16; 'iteration': 0.16; 'loops': 0.16; 'nothing.':
0.16; 'odd': 0.16; 'photo-blog': 0.16; 'received:(vzm hermes smtp
server)': 0.16; 'something.': 0.16; 'sort,': 0.16; 'turns': 0.16;
'url-ip:79.170.44.132/32': 0.16; 'url-ip:79.170.44/24': 0.16;
'url-ip:79.170/16': 0.16; 'url-ip:79/8': 0.16; 'url:alan-g': 0.16;
'url:alan_gauld': 0.16; 'url:alangauldphotos': 0.16; 'variant':
0.16; 'while,': 0.16; 'wrote:': 0.16; 'python': 0.16; 'instead':
0.17; 'probably': 0.17; 'uses': 0.19; 'url:amazon': 0.19; 'to:addr
:python-list': 0.20; 'language': 0.21; 'written': 0.22;
'languages': 0.22; 'code': 0.23; 'skip:- 10': 0.25; 'url-
ip:188.166.95.178/32': 0.25; 'url-ip:188.166.95/24': 0.25;
'url:listinfo': 0.25; 'cannot': 0.25; 'url-ip:188.166/16': 0.25;
'11,': 0.26; 'again,': 0.26; 'interface': 0.26; 'stefan': 0.26;
'suspect': 0.26; 'url-ip:104.85.6.101/32': 0.26; 'url-
ip:104.85.6/24': 0.26; 'else': 0.27; 'done': 0.28; 'expect': 0.28;
'computer': 0.29; 'error': 0.29; 'url-ip:188/8': 0.31; 'program':
0.31; 'think': 0.32; 'everyone': 0.32; 'assume': 0.32; 'attach':
0.32; 'do.': 0.32; 'friday': 0.32; 'happening': 0.32; 'logical':
0.32; 'point,': 0.32; 'python-list': 0.32; 'secondary': 0.32;
'structure': 0.32; 'but': 0.32; "i'm": 0.33; 'there': 0.33;
'mean': 0.34; 'header:In-Reply-To:1': 0.34; 'failed': 0.35;
'item': 0.35; 'meaning': 0.35; 'runs': 0.35; 'words': 0.35;
'look': 0.65; 'outside': 0.67; 'that,': 0.67; 'url-ip:13.249/16':
0.68; 'right': 0.68; 'items': 0.68; 'matter': 0.68; 'drop': 0.69;
'perfectly': 0.69; 'sentence': 0.69; 'url:author': 0.69; 'within':
0.69; 'site': 0.70; 'above,': 0.70; 'experience.': 0.70; 'front':
0.70; 'rules': 0.70; 'them,': 0.70; '2021': 0.71; 'interesting':
0.71; 'sent:': 0.78; 'partner': 0.78; 'returned': 0.81; 'url-
ip:13.249.48/24': 0.81; '"when': 0.84; 'alike': 0.84; 'choices':
0.84; 'clause': 0.84; 'inconsistent': 0.84; 'minor': 0.84;
'naturally': 0.84; 'noted': 0.84; 'pointing': 0.84;
'received:74.6.133.124': 0.84;
'received:sonic313-14.consmr.mail.bf2.yahoo.com': 0.84;
'saturday,': 0.84; 'sentences': 0.84; 'succeeded': 0.84; 'sunny':
0.84; 'opposite': 0.91; 'refuses': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=verizon.net; s=a2048;
t=1631392178; bh=e/k2iIZ9t2ZxFawlQHrMjXo34fLba0gBAdm7+irRi/A=;
h=From:To:References:In-Reply-To:Subject:Date:From:Subject:Reply-To;
b=Y1G6XZW8WWrsxfb2d07AR9ZO7+9XBzt9qh6fFARIe8vrz+RVeDIoF8cJYT2EZjlB0+W/ZB2K+2NtPpdXp7Y5tNoolIY4sJa2ylNV7SFiSEp5MajGxQqvuLLVIEAPGZxT6VyVDNAHJR7H0u831x6T6WomJdXvCJQTZih6glP4vuMhCYInvPIrZr6uXoaRz6KUXhZgc8BwpJdmyc1Hdj22tv5fOekBeJQhCK6IMRz4YTn6UWJSfnA51MDko20I2veB8aVJAQW1S9Fy0cPlx1wnt47v+SMwW2QfPZATZ2Y1r3TEROJG4Ht8sX+YRQwmoH2vOndZlz5gvDVhT3KIdjB62g==
X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048;
t=1631392178; bh=cv01HmXmjcJaJhZp4KdxBEj3IPqiz/9Mtsj+NMagb4u=;
h=X-Sonic-MF:From:To:Subject:Date:From:Subject;
b=hpSV+yyCa2PlH8rfxf4RhmKS6M7ppFu/eLWDIKEaMgIaFysGnk5djNNXGHDrYZ6NnVotFp42eIsn2vCjJgTjIcPyqQSHRGa3LKPwjXsxIEjrVGb0p2MHBkIvoUPYhjdrBdi2yC5dvMQtOYngiwjaDkEC624H3nKjn1Rb4WuVNxdhy/DleSB2roYF7LjKoUZd5k8BgHgwsaD1kL2uYQn5wxz1K9lelt712NK1ZDXU5I9DkcQLhse29xLMq7k0ZmVyehcpxI+EfQ2+L5/04boNUQcJTrhrYmXI859MXk2zJHV1BgDa6D5Hr4NwqY619/d7s4TcHXPPnFanSLC+EbK8Kw==
X-YMail-OSG: eXdW8SsVM1kyPSvleNEB2PA1Q.CiQScmsjeINO6l7onkB.vJ_JNE0k6WUjEy2c5
LS4O1lMXrRMIAGIZ07IoeMSC76obxmCaC33dg_qC4GXD0JJAc8bfsnFcgpFAsKapFzkp5rfDnRcG
avRQ9qwOlfcL53y7JIXzj0WfcAITAg7kll9qz8tzIJQvTXiy2uCcNXtKTP40ZQglFkt9T3js7zF5
Q.5lvyi8q5Zgnjoeaq0vrtzcSLRwdH54dPJRRqtIlCbzfeZGRUVIjNFxgifONLNv7C9lBwBgMVGt
MUEKSrHQgPqvrLRscZMoqE4z9GFw2BaEVwcQy3Qjk85oYPaGAUtsTZ64DOcnwkS2jqMP4eMGXKzv
PzhCONC5GAKZe5CJCbhdggC0d_cabSIDanHxTzhUfaZ56JJGU6dISi.xHDI9Qu8qq4V05bNcjLE9
lUume4f_uInwPtFAyJvYlTzW89yZypvZokrDqf8ggRX4H6VECfd9T8Qf2XKNWvbLfGhLAt.PS8Ko
fGmyb3l5zRWGBK5DwNPM54kfcHf1TLWkV2QZ3yw5IDQma6w6X3vIPlL1qwhUhY7BTq_gSPqO8DGI
jcCIAjcmffwxSzvNvQQ_i4TIYDwcPM4_z0qQjVem_lzKMvO0q4SKDO5f3.MYgi0TLBshgjUIL3_7
C3gPv7JDi7YUqlU7M_TxXrX_Ol1xQ35fKL4NfO6SCYW0JSNWgvXth.L6l8tTl8fI6le9tuiGJrYD
rDN7xGK3PfJpF39Dg5MjU8pSayiJR2IYoBICxVj_IuL0odi4ej1qEvuk092Pl_TpcUbJlTGG8.Dm
pCAchtVUkXhP_7S_Uxx_g_PStHJHOiKtTXxtp1ZfTyTvAzXYm3XmEFwTMc2hBX8Aa_e0fVqY4DPv
u93cVXbz.g6wIDxaYa7tjy54oL3mE0pdJmQnZplnAeI_usieqqb5FXG_IO2Jmm2zyq6s7WpB61xH
maQNjy3Ib3XAbt4Xc28ZCnb1fbXz0SMcYaoCTnHCNR.hnRlwisDckkeOms2WoiaqBrhjrXUsWXQn
LThc_ThZnTpe_V_UveBqg.JWm7vt2QRkyIXcNrcLhzhH2.pkdNAlAczL4bEDoBop5RfDPxXbPBb6
zeJLZ_._IimE3_nSh6_AlCzGp7H7hTLx7bvlxiydViasDAdZJakU_MJjFvs4MT0z_vnit05EdE1i
tsjnvL6QMn3vi3Bjh.aPHUNo2IuJOng97euy2BqsSFwRDMjg4H68F_laUhJIXqdeOEjbtuo14TcQ
ZEUccPHXjrhETV12usnCIfNZPhrlnLni9Spucd2_R1mvwxQWN.R70FD0qQlYxye0cGL48qEhSABH
4rdZ4p6ZxXb.HnSfhIRmgpxKo8s6UKDS9xOjlcIUmQyjVNI8ll556jDH0XxLeScUFsv58KotPA8a
ojeQ_JYIntfb1PscKdoTObkPfWP44tUOSX8fybILNe2DGjay.r0zGSbfL5f5yJ3bwHBp4SVIUY_X
62HkqhAYSBuxP1VNolpi_gCAbVCAtxqKi91UwEUYQFsko60QYY1Eud2X8BMXavXyv_4ES_BG99N1
MwI9ouT.1.6LGGt2rlpMu99y8EQmBpT1l4itGvB..6zqV._ANZwlzn33kNyx7Qrl.6IkEgkSPpK0
VFrOjzBWYdf6Tfx4DfN.sLDMz.8EVENopHh.9da9NeeaYNfRq1Is0gtqfuCX55.dUNOXNl9YERqb
JO17A.2DgM68SEZ4NXAqhcXguOrKpC4eAfIzoiE5UWmVqQZas3t2RNRfdv8hf6VZZgWYodlsZK._
09czGmNZOs9o6UlF1ANwokfKzGp9FYgtwlbTqWNRiYdpSeIuYSPNzdeaSlLTlhj09fkj64QMk6Cm
jti8AQR2JFbnU7FWVewMpmB1eksdT.aNR2IgIYrYlnwjPSTV6.s0h2MLu7sR1pgp1pliG.75jYqN
3oWcmj.J.4tu9jSJ90dHOasP38PocWc70tOxTl1ECEaslM3nDozZpdsTIylAhuzMhsBTjZNY_4hx
lu0k7SLPHt1dgel2LKUPZApEcHwg93tMLdJBeFgSNybPNVNmY91DvhRlcGdOh7EdhoKd_fYg6Tt.
5FeEDJuQjnL4eVHQoy8SwDkacavAUIpXwL3SYJKhMUhr4gdlG7.Crc42iXhoE4hsZxUK8wA50Ikl
YCTEzZXrKrlepDja3d0FrYZmSf_vFOdCvQ9OWToW4ulgTMo3mNFCDhNPXVSvZNgUqjMZg7ydHfbQ
bQcBDFJ2NecYP_FQP8cubVreMOR7gIE9Z4ocvHNctX3Fj6p7GEcPmzPP9trokcwA-
X-Sonic-MF: <avigross@verizon.net>
In-Reply-To: <shhnk5$bvr$1@ciao.gmane.io>
X-Mailer: Microsoft Outlook 16.0
Content-Language: en-us
Thread-Index: AQH8RFnQrsJfLkU50XE9+Q5aLLwBIgIW7iPlAeza6vACAh1gnwDk5jNpAN0UsksC5rePQasAj5tw
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: <041f01d7a74b$bd3d83b0$37b88b10$@verizon.net>
X-Mailman-Original-References: <097bf31d-44e8-da35-df41-3834524716c9@DancesWithMice.info>
<shfg3i$4e6$1@ciao.gmane.io>
<05c4abc0-70b6-b2ea-7cfa-1121d75d2126@mrabarnett.plus.com>
<shfv9j$dii$1@ciao.gmane.io>
<mailman.686.1631298676.4164.python-list@python.org>
<Beginners-20210910194859@ram.dialup.fu-berlin.de>
<shhnk5$bvr$1@ciao.gmane.io>
 by: Avi Gross - Sat, 11 Sep 2021 20:29 UTC

Alan and others,

I think human languages used to make computer languages will often cause
confusion.

Some languages have an IF .. ELSE construct but also an EITHER ... OR and a
NEITHER ... NOR and other twists and turns like words that sometimes come
apart and you end up having to dangle a part that was in the front of a word
to later in the sentence and so on.

But I suspect many languages do NOT naturally have a construct like:

WHILE ... ELSE.

The might have a sentence like "While it is sunny you should use sunscreen
but when it rains use an umbrella." It probably is even a tad deceptive to
use WHILE in one part and not in the other. Perfectly valid sentences are
"When going outside if it is sunny use sunscreen but if it is rainy use an
umbrella" or skip the while and use a more standard if/else. The world
"while" just does not feel like a partner for "else".

So say you want to have a loop starting with WHILE and FOLLOWED by a single
ELSE clause. Arguably you could make WHILE as a construct return a status of
sorts if it runs at all or perhaps if it exits after at least one iteration
because the condition evaluates to FALSE. It would either return false if
you exit with a BREAK or by an error or perhaps not exit at all if you do a
return from within.

So if you made up a syntax like:

IF (WHILE condition {...})
ELSE {...}

Then what would that mean? Again, this is a make-believe construct. In the
above, if WHILE returned a True of some sort, the else is skipped.
Otherwise, no matter what has been done within the while loop, it is done.

But as noted we have odd choices here potentially. Could we differentiate
between a BREAK statement within and something like BREAK OK variant that
means the while is to be treated as succeeded and please do not do the
trailing ELSE? I can see many possible ways to design things and cannot
expect humans to automatically assume the specific nomenclature will be
meaningful to them.

There is an alternative that people who are not damn sure what the meaning
is can do. Create a variable that is set to False or True to represent
something before the WHILE is entered. Then make sure your code flips that
value in cased you want to make sure a trailing statement is run. Then
following the while, you place an IF statement that tests that variable and
does what the ELSE cluse would have done, or not.

Looking at other constructs, look at this code with a try:

i=0
while i<5:
try:
assert(i!=3) #Raises an AssertionError if i==3
print("i={0}".format(i))
except:
continue
finally:
i+= 1; #Increment i

Now attach an ELSE clause to the WHILE, LOL!

At some point, van some humans decide just not to write the code this way?

What about code that uses CONTINUE to the point where you enter the WHILE
statement and get a secondary IF or something that keeps triggering a
CONTINUE to start the next iteration. Arguably, this can effectively mean
the WHILE loop did nothing. An example would be evaluating the contents of a
data structure like a list and adding all numeric items together and
ignoring any that are character strings. Given all characters, no summation
is done. The first statement in the loop tests a list item and does a
CONTINUE. But by the rules as I see them, the loop was entered. Yet, a
similar loop written where the WHILE condition simply tests if ANY item is
numeric, might drop right through to an ELSE clause.

Bottom line is humans do not all think alike and language constructs that
are clear and logical to one may be confusing or mean the opposite to
others.

I can even imagine designing an interface like this:

WHILE (condition):
...
IF_NOT_RUN:
...
IF_EXITED_EARLY:
...
IF_ERROR_THROWN:
...
ON_PREMATURE_RETURN_DO_THIS:
...

I am not suggesting we need critters like that, simply that ELSE is a grab
bag case that can mean many things to many people.

But if the specific meaning is clearly documented, use it. Lots of people
who program in languages like Python do not necessarily even speak much
English and just memorize the keywords.

We can come up with ever more interesting or even bizarre constructs like
multiple WHILE in a row with each one being called only if the previous one
failed to process the data. An example might be if each tests the data type
and refuses to work on it so the next one in line is called. That could
perhaps be done by having multiple ELSE statements each with another WHILE.
But is that an ideal way to do this or perhaps instead use some variant of a
switch statement or a dictionary pointing to functions to invoke or
something.

Time to go do something lese of even minor usefulness!

-----Original Message-----
From: Python-list <python-list-bounces+avigross=verizon.net@python.org> On
Behalf Of Alan Gauld via Python-list
Sent: Saturday, September 11, 2021 3:59 AM
To: python-list@python.org
Subject: Re: Friday Finking: Contorted loops

On 10/09/2021 19:49, Stefan Ram wrote:
> Alan Gauld <alan.gauld@yahoo.co.uk> writes:
>> OK, That's a useful perspective that is at least consistent.
>> Unfortunately it's not how beginners perceive it
> ...
>
> Beginners perceive it the way it is explained to them by
> their teacher.

I'm not sure that's true. Most beginners, in my experience, learn the
syntax from their teachers and then go off and play.
What they observe happening is what sticks. And python loop 'else'
constructs appear inconsistent to them.

As teachers we like to think we are passing on our wisdom to our students
but in reality everyone learns from their own experience. The teachers
advice is just the starting point. Hopefully, that starting point sends them
in the right direction but that's the best we can hope for.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos

--
https://mail.python.org/mailman/listinfo/python-list

Re: Friday Finking: Contorted loops

<1bczpeg4fu.fsf@pfeifferfamily.net>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: pfeiffer@cs.nmsu.edu (Joe Pfeiffer)
Newsgroups: comp.lang.python
Subject: Re: Friday Finking: Contorted loops
Date: Sat, 11 Sep 2021 15:58:29 -0600
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <1bczpeg4fu.fsf@pfeifferfamily.net>
References: <097bf31d-44e8-da35-df41-3834524716c9@DancesWithMice.info>
<shfg3i$4e6$1@ciao.gmane.io>
<05c4abc0-70b6-b2ea-7cfa-1121d75d2126@mrabarnett.plus.com>
<shfv9j$dii$1@ciao.gmane.io>
<mailman.686.1631298676.4164.python-list@python.org>
<Beginners-20210910194859@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="22335859b430d29a5a22779f0de710db";
logging-data="4922"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/OOBqvEeAw3VRaoI7O2gy4V8HFZDA99HQ="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:zU3LfBXHyRPUUPiZ0uZ6Fmxy2aI=
sha1:aycsV33pvQOk1nRZJcxIa2Sz13I=
 by: Joe Pfeiffer - Sat, 11 Sep 2021 21:58 UTC

ram@zedat.fu-berlin.de (Stefan Ram) writes:

> Alan Gauld <alan.gauld@yahoo.co.uk> writes:
>>OK, That's a useful perspective that is at least consistent.
>>Unfortunately it's not how beginners perceive it
> ...
>
> Beginners perceive it the way it is explained to them by
> their teacher.

My life as a professor would have been *so* much easier if that were
true...

Re: Friday Finking: Contorted loops

<87wnnm7ofq.fsf@nightsong.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.email@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.python
Subject: Re: Friday Finking: Contorted loops
Date: Sat, 11 Sep 2021 15:11:21 -0700
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <87wnnm7ofq.fsf@nightsong.com>
References: <097bf31d-44e8-da35-df41-3834524716c9@DancesWithMice.info>
<shfg3i$4e6$1@ciao.gmane.io>
<05c4abc0-70b6-b2ea-7cfa-1121d75d2126@mrabarnett.plus.com>
<shfv9j$dii$1@ciao.gmane.io>
<mailman.686.1631298676.4164.python-list@python.org>
<Beginners-20210910194859@ram.dialup.fu-berlin.de>
<1bczpeg4fu.fsf@pfeifferfamily.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="ba54d55f56f7c6ebe10fbd14de294cd6";
logging-data="11293"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/kzvkJTqtoZKEplBei22Jw"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Cancel-Lock: sha1:rPaKQQOqT4g2T1wLDPjiOIh1JFE=
sha1:r645DAMd2udVJqTCghXA92jXHmk=
 by: Paul Rubin - Sat, 11 Sep 2021 22:11 UTC

Joe Pfeiffer <pfeiffer@cs.nmsu.edu> writes:
> My life as a professor would have been *so* much easier if that were
> true...

From Ed Nelson, "Reflections on retirement",
https://web.math.princeton.edu/~nelson/papers/retirement.pdf :

Teaching freshman calculus is fun, but it poses very different
challenges from graduate teaching. A few years ago while grading the
final exam, I felt an increasing sense of frustration that I couldn’t
articulate. Finally I was able to put it into words: “I’ve been teaching
these kids forty years and still they don’t understand!”

Re: Friday Finking: Contorted loops

<shk8c1$122u$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!aioe.org!7ngI4xJTvjOBYwCWXQjLiQ.user.46.165.242.91.POSTED!not-for-mail
From: nospam@please.ty (jak)
Newsgroups: comp.lang.python
Subject: Re: Friday Finking: Contorted loops
Date: Sun, 12 Sep 2021 08:56:56 +0200
Organization: Aioe.org NNTP Server
Message-ID: <shk8c1$122u$1@gioia.aioe.org>
References: <097bf31d-44e8-da35-df41-3834524716c9@DancesWithMice.info>
<shfg3i$4e6$1@ciao.gmane.io>
<05c4abc0-70b6-b2ea-7cfa-1121d75d2126@mrabarnett.plus.com>
<shfv9j$dii$1@ciao.gmane.io>
<mailman.686.1631298676.4164.python-list@python.org>
<Beginners-20210910194859@ram.dialup.fu-berlin.de>
<shhnk5$bvr$1@ciao.gmane.io> <041f01d7a74b$bd3d83b0$37b88b10$@verizon.net>
<mailman.705.1631392181.4164.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="34910"; posting-host="7ngI4xJTvjOBYwCWXQjLiQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Content-Language: it
X-Notice: Filtered by postfilter v. 0.9.2
 by: jak - Sun, 12 Sep 2021 06:56 UTC

Il 11/09/2021 22:29, Avi Gross ha scritto:
>
> Alan and others,
>
> I think human languages used to make computer languages will often cause
> confusion.
>
> Some languages have an IF .. ELSE construct but also an EITHER ... OR and a
> NEITHER ... NOR and other twists and turns like words that sometimes come
> apart and you end up having to dangle a part that was in the front of a word
> to later in the sentence and so on.
>
> But I suspect many languages do NOT naturally have a construct like:
>
> WHILE ... ELSE.
>
> The might have a sentence like "While it is sunny you should use sunscreen
> but when it rains use an umbrella." It probably is even a tad deceptive to
> use WHILE in one part and not in the other. Perfectly valid sentences are
> "When going outside if it is sunny use sunscreen but if it is rainy use an
> umbrella" or skip the while and use a more standard if/else. The world
> "while" just does not feel like a partner for "else".
>
> So say you want to have a loop starting with WHILE and FOLLOWED by a single
> ELSE clause. Arguably you could make WHILE as a construct return a status of
> sorts if it runs at all or perhaps if it exits after at least one iteration
> because the condition evaluates to FALSE. It would either return false if
> you exit with a BREAK or by an error or perhaps not exit at all if you do a
> return from within.
>
> So if you made up a syntax like:
>
> IF (WHILE condition {...})
> ELSE {...}
>
> Then what would that mean? Again, this is a make-believe construct. In the
> above, if WHILE returned a True of some sort, the else is skipped.
> Otherwise, no matter what has been done within the while loop, it is done.
>
> But as noted we have odd choices here potentially. Could we differentiate
> between a BREAK statement within and something like BREAK OK variant that
> means the while is to be treated as succeeded and please do not do the
> trailing ELSE? I can see many possible ways to design things and cannot
> expect humans to automatically assume the specific nomenclature will be
> meaningful to them.
>
> There is an alternative that people who are not damn sure what the meaning
> is can do. Create a variable that is set to False or True to represent
> something before the WHILE is entered. Then make sure your code flips that
> value in cased you want to make sure a trailing statement is run. Then
> following the while, you place an IF statement that tests that variable and
> does what the ELSE cluse would have done, or not.
>
> Looking at other constructs, look at this code with a try:
>
> i=0
> while i<5:
> try:
> assert(i!=3) #Raises an AssertionError if i==3
> print("i={0}".format(i))
> except:
> continue
> finally:
> i+= 1; #Increment i
>
> Now attach an ELSE clause to the WHILE, LOL!
>
> At some point, van some humans decide just not to write the code this way?
>
> What about code that uses CONTINUE to the point where you enter the WHILE
> statement and get a secondary IF or something that keeps triggering a
> CONTINUE to start the next iteration. Arguably, this can effectively mean
> the WHILE loop did nothing. An example would be evaluating the contents of a
> data structure like a list and adding all numeric items together and
> ignoring any that are character strings. Given all characters, no summation
> is done. The first statement in the loop tests a list item and does a
> CONTINUE. But by the rules as I see them, the loop was entered. Yet, a
> similar loop written where the WHILE condition simply tests if ANY item is
> numeric, might drop right through to an ELSE clause.
>
> Bottom line is humans do not all think alike and language constructs that
> are clear and logical to one may be confusing or mean the opposite to
> others.
>
> I can even imagine designing an interface like this:
>
> WHILE (condition):
> ...
> IF_NOT_RUN:
> ...
> IF_EXITED_EARLY:
> ...
> IF_ERROR_THROWN:
> ...
> ON_PREMATURE_RETURN_DO_THIS:
> ...
>
> I am not suggesting we need critters like that, simply that ELSE is a grab
> bag case that can mean many things to many people.
>
> But if the specific meaning is clearly documented, use it. Lots of people
> who program in languages like Python do not necessarily even speak much
> English and just memorize the keywords.
>
> We can come up with ever more interesting or even bizarre constructs like
> multiple WHILE in a row with each one being called only if the previous one
> failed to process the data. An example might be if each tests the data type
> and refuses to work on it so the next one in line is called. That could
> perhaps be done by having multiple ELSE statements each with another WHILE.
> But is that an ideal way to do this or perhaps instead use some variant of a
> switch statement or a dictionary pointing to functions to invoke or
> something.
>
> Time to go do something lese of even minor usefulness!
>
> -----Original Message-----
> From: Python-list <python-list-bounces+avigross=verizon.net@python.org> On
> Behalf Of Alan Gauld via Python-list
> Sent: Saturday, September 11, 2021 3:59 AM
> To: python-list@python.org
> Subject: Re: Friday Finking: Contorted loops
>
> On 10/09/2021 19:49, Stefan Ram wrote:
>> Alan Gauld <alan.gauld@yahoo.co.uk> writes:
>>> OK, That's a useful perspective that is at least consistent.
>>> Unfortunately it's not how beginners perceive it
>> ...
>>
>> Beginners perceive it the way it is explained to them by
>> their teacher.
>
> I'm not sure that's true. Most beginners, in my experience, learn the
> syntax from their teachers and then go off and play.
> What they observe happening is what sticks. And python loop 'else'
> constructs appear inconsistent to them.
>
> As teachers we like to think we are passing on our wisdom to our students
> but in reality everyone learns from their own experience. The teachers
> advice is just the starting point. Hopefully, that starting point sends them
> in the right direction but that's the best we can hope for.
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>

An inconsistency that I have been able to notice is this:
someone suggests to remedy the absence of the do-while with:
while True:
...
if condition:
break
the problem arises if the while has an else of its own because the break
not only blocks the while loop but will also ignore the relative else.

Re: Friday Finking: Contorted loops

<shkcnd$m6m$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!aioe.org!7ngI4xJTvjOBYwCWXQjLiQ.user.46.165.242.91.POSTED!not-for-mail
From: nospam@please.ty (jak)
Newsgroups: comp.lang.python
Subject: Re: Friday Finking: Contorted loops
Date: Sun, 12 Sep 2021 10:11:15 +0200
Organization: Aioe.org NNTP Server
Message-ID: <shkcnd$m6m$1@gioia.aioe.org>
References: <097bf31d-44e8-da35-df41-3834524716c9@DancesWithMice.info>
<shfg3i$4e6$1@ciao.gmane.io>
<05c4abc0-70b6-b2ea-7cfa-1121d75d2126@mrabarnett.plus.com>
<shfv9j$dii$1@ciao.gmane.io>
<mailman.686.1631298676.4164.python-list@python.org>
<Beginners-20210910194859@ram.dialup.fu-berlin.de>
<shhnk5$bvr$1@ciao.gmane.io> <041f01d7a74b$bd3d83b0$37b88b10$@verizon.net>
<mailman.705.1631392181.4164.python-list@python.org>
<shk8c1$122u$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="22742"; posting-host="7ngI4xJTvjOBYwCWXQjLiQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Content-Language: it
X-Notice: Filtered by postfilter v. 0.9.2
 by: jak - Sun, 12 Sep 2021 08:11 UTC

-- snip --
>
> An inconsistency that I have been able to notice is this:
> someone suggests to remedy the absence of the do-while with:
> while True:
>      ...
>      if condition:
>          break
> the problem arises if the while has an else of its own because the break
> not only blocks the while loop but will also ignore the relative else.
>

I will try to make my doubt clearer:
if the only way to terminate a 'while True' loop is by using the 'break'
statement, why is it allowed to add the 'else' statement which will only
contain dead code?

while True:
break
else:
print('dead code')

Re: Friday Finking: Contorted loops

<shl1eh$1kcm$2@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!aioe.org!JKO1PkfLTHZS2rvPG0IJWA.user.46.165.242.75.POSTED!not-for-mail
From: alister.ware@ntlworld.com (alister)
Newsgroups: comp.lang.python
Subject: Re: Friday Finking: Contorted loops
Date: Sun, 12 Sep 2021 14:05:05 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <shl1eh$1kcm$2@gioia.aioe.org>
References: <097bf31d-44e8-da35-df41-3834524716c9@DancesWithMice.info>
<shfg3i$4e6$1@ciao.gmane.io>
<05c4abc0-70b6-b2ea-7cfa-1121d75d2126@mrabarnett.plus.com>
<shfv9j$dii$1@ciao.gmane.io>
<mailman.686.1631298676.4164.python-list@python.org>
<Beginners-20210910194859@ram.dialup.fu-berlin.de>
<shhnk5$bvr$1@ciao.gmane.io> <041f01d7a74b$bd3d83b0$37b88b10$@verizon.net>
<mailman.705.1631392181.4164.python-list@python.org>
<shk8c1$122u$1@gioia.aioe.org> <shkcnd$m6m$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="53654"; posting-host="JKO1PkfLTHZS2rvPG0IJWA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Pan/0.146 (Hic habitat felicitas; 8107378
git@gitlab.gnome.org:GNOME/pan.git)
X-Notice: Filtered by postfilter v. 0.9.2
 by: alister - Sun, 12 Sep 2021 14:05 UTC

On Sun, 12 Sep 2021 10:11:15 +0200, jak wrote:

> -- snip --
>>
>> An inconsistency that I have been able to notice is this:
>> someone suggests to remedy the absence of the do-while with:
>> while True:
>>      ...
>>      if condition:
>>          break
>> the problem arises if the while has an else of its own because the
>> break not only blocks the while loop but will also ignore the relative
>> else.
>>
>>
> I will try to make my doubt clearer:
> if the only way to terminate a 'while True' loop is by using the 'break'
> statement, why is it allowed to add the 'else' statement which will only
> contain dead code?
>
> while True:
> break
> else:
> print('dead code')

Because adjusting the parser for one specific special case is not worth
the effort.
it is not the job of the interpreter to sanitise stupid programming

"Special Cases aren't special enough the break the rules"

--
If you stew apples like cranberries, they taste more like prunes than
rhubarb does.
-- Groucho Marx

Re: Friday Finking: Contorted loops

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: alan.gauld@yahoo.co.uk (Alan Gauld)
Newsgroups: comp.lang.python
Subject: Re: Friday Finking: Contorted loops
Date: Sun, 12 Sep 2021 18:25:05 +0100
Lines: 32
Message-ID: <mailman.717.1631493562.4164.python-list@python.org>
References: <097bf31d-44e8-da35-df41-3834524716c9@DancesWithMice.info>
<shfg3i$4e6$1@ciao.gmane.io>
<05c4abc0-70b6-b2ea-7cfa-1121d75d2126@mrabarnett.plus.com>
<shfv9j$dii$1@ciao.gmane.io>
<mailman.686.1631298676.4164.python-list@python.org>
<Beginners-20210910194859@ram.dialup.fu-berlin.de>
<shhnk5$bvr$1@ciao.gmane.io> <041f01d7a74b$bd3d83b0$37b88b10$@verizon.net>
<mailman.705.1631392181.4164.python-list@python.org>
<shk8c1$122u$1@gioia.aioe.org> <shkcnd$m6m$1@gioia.aioe.org>
<shld5l$6dk$1@ciao.gmane.io>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de zvGP1fl/kGCLhii2NmaSxQmiT+rQjqURoTVu5wsliIXA==
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.001
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'loop': 0.07; 'code?':
0.09; 'else:': 0.09; 'likewise': 0.09; 'message-
id:@ciao.gmane.io': 0.09; 'received:ciao.gmane.io': 0.09;
'received:gmane.io': 0.09; 'received:list': 0.09; 'flickr': 0.16;
'from:addr:alan.gauld': 0.16; 'from:name:alan gauld': 0.16;
'interpreter': 0.16; 'photo-blog': 0.16; 'received:116.202': 0.16;
'received:116.202.254': 0.16; 'received:116.202.254.214': 0.16;
'redundant': 0.16; 'url-ip:79.170.44.132/32': 0.16; 'url-
ip:79.170.44/24': 0.16; 'url-ip:79.170/16': 0.16; 'url-ip:79/8':
0.16; 'url:alan-g': 0.16; 'url:alan_gauld': 0.16;
'url:alangauldphotos': 0.16; 'wrote:': 0.16; 'python': 0.16;
'code.': 0.17; 'url:amazon': 0.19; 'to:addr:python-list': 0.20;
'code': 0.23; 'anyone': 0.25; 'url-ip:104.85.6.101/32': 0.26;
'url-ip:104.85.6/24': 0.26; 'else': 0.27; 'header:User-Agent:1':
0.30; 'program': 0.31; 'language.': 0.32; 'header:In-Reply-To:1':
0.34; 'using': 0.37; 'author': 0.37; 'way': 0.38; 'use': 0.39;
'break': 0.39; 'alan': 0.40; 'learn': 0.40; 'follow': 0.62;
'identify': 0.64; 'received:116': 0.64; 'url-ip:13.249/16': 0.68;
'url:author': 0.69; 'site': 0.70; 'dead': 0.81; 'url-
ip:13.249.48/24': 0.81; 'clause': 0.84; 'true:': 0.84; 'warning':
0.84
X-Injected-Via-Gmane: http://gmane.org/
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
In-Reply-To: <shkcnd$m6m$1@gioia.aioe.org>
Content-Language: en-GB
X-Mailman-Approved-At: Sun, 12 Sep 2021 20:39:20 -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: <shld5l$6dk$1@ciao.gmane.io>
X-Mailman-Original-References: <097bf31d-44e8-da35-df41-3834524716c9@DancesWithMice.info>
<shfg3i$4e6$1@ciao.gmane.io>
<05c4abc0-70b6-b2ea-7cfa-1121d75d2126@mrabarnett.plus.com>
<shfv9j$dii$1@ciao.gmane.io>
<mailman.686.1631298676.4164.python-list@python.org>
<Beginners-20210910194859@ram.dialup.fu-berlin.de>
<shhnk5$bvr$1@ciao.gmane.io> <041f01d7a74b$bd3d83b0$37b88b10$@verizon.net>
<mailman.705.1631392181.4164.python-list@python.org>
<shk8c1$122u$1@gioia.aioe.org> <shkcnd$m6m$1@gioia.aioe.org>
 by: Alan Gauld - Sun, 12 Sep 2021 17:25 UTC

On 12/09/2021 09:11, jak wrote:

> if the only way to terminate a 'while True' loop is by using the 'break'
> statement, why is it allowed to add the 'else' statement which will only
> contain dead code?
>
> while True:
> break
> else:
> print('dead code')
>
Because to the interpreter the condition is not part of the
language. It is syntactically correct.

An optimiser OTOH might welkl determine that the condition
will never fail and therefore the else clause never be reached,
in which case it would remove the dead code (possibly emitting
a warning in the process?).

A linter likewise might identify the redundant code.
I don't use any python linters, does anyone know if they do
detect such dead spots?

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


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

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor