Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

It's not an optical illusion, it just looks like one. -- Phil White


devel / comp.lang.python / Re: Behavior of the for-else construct

SubjectAuthor
o Re: Behavior of the for-else constructgene heskett

1
Re: Behavior of the for-else construct

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ghesk...@shentel.net (gene heskett)
Newsgroups: comp.lang.python
Subject: Re: Behavior of the for-else construct
Date: Fri, 04 Mar 2022 05:01:09 -0500
Organization: only accidental
Lines: 69
Message-ID: <mailman.158.1646388081.2329.python-list@python.org>
References: <CALq4Z0-fJk-HOu0ka2kPrOioPYAh3e3zbziwetUDmAAx1U1LMw@mail.gmail.com>
<25121.48093.26762.592197@ixdm.fritz.box>
<CAPTjJmp0BQ0y5atoJS5+NK2zt3RQr7G4r=5=XHzGq8SCcXcUYA@mail.gmail.com>
<4392817.Tn9u4OIKmF@coyote>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7Bit
X-Trace: news.uni-berlin.de WvEsnlTQSoprxo0Cgx40OgLjRxqycAG3gB5ONz39H7BA==
Return-Path: <gheskett@shentel.net>
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; 'traceback': 0.04; '(most':
0.05; '2022': 0.05; 'last):': 0.05; 'received:204': 0.05;
'variable': 0.05; 'e.g.': 0.07; 'loop': 0.07; 'mar': 0.07;
'angelico': 0.09; 'construct': 0.09; 'else:': 0.09; 'cheers,':
0.11; 'url:mailman': 0.15; 'memory': 0.15; '"there': 0.16; '-ed':
0.16; 'ammo.': 0.16; 'ballot,': 0.16; 'brandeis': 0.16; 'chrisa':
0.16; 'demonstrated': 0.16; 'desire': 0.16; 'dieter': 0.16;
'from:addr:gheskett': 0.16; 'from:addr:shentel.net': 0.16;
'from:name:gene heskett': 0.16; 'howdershelt': 0.16; 'idea.':
0.16; 'jury,': 0.16; 'liberty:': 0.16; 'loop?': 0.16; 'matched':
0.16; 'named.': 0.16; 'order."': 0.16; 'received:204.111': 0.16;
'received:204.111.64': 0.16; 'received:204.111.64.149': 0.16;
'respectable.': 0.16; 'skip:> 10': 0.16; 'soap,': 0.16; 'stack.':
0.16; 'subject:else': 0.16; 'thats': 0.16; 'wrote:': 0.16;
'to:addr:python-list': 0.20; 'fri,': 0.22; "what's": 0.22; '(and':
0.25; 'url-ip:188.166.95.178/32': 0.25; 'url-ip:188.166.95/24':
0.25; 'url:listinfo': 0.25; 'url-ip:188.166/16': 0.25; 'anyone':
0.25; 'friday,': 0.26; 'else': 0.27; '>>>': 0.28; 'chris': 0.28;
'this?': 0.29; 'it,': 0.29; 'comment': 0.31;
'header:Organization:1': 0.31; 'url-ip:188/8': 0.31; '"",': 0.32;
'but': 0.32; 'subject:for': 0.33; 'march': 0.33; 'header:In-Reply-
To:1': 0.34; 'item': 0.35; 'respect': 0.35; 'following': 0.35;
'cases': 0.36; 'work,': 0.36; 'really': 0.37; 'hard': 0.37;
'file': 0.38; 'means': 0.38; 'put': 0.38; 'read': 0.38; 'enough':
0.39; 'use': 0.39; 'break': 0.39; 'wrote': 0.39; 'want': 0.40;
'four': 0.60; 'law': 0.60; 'remember': 0.61; 'here': 0.62; 'pass':
0.64; 'involve': 0.64; 'similar': 0.65; 'est': 0.69; 'law,': 0.69;
'perfectly': 0.69; 'sequence': 0.69; '1940)': 0.84; 'code)': 0.84;
'means,': 0.84; 'none"': 0.84; 'received:mail': 0.84; 'remind':
0.84; 'rob': 0.84
auth-sender: gheskett@shentel.net
In-Reply-To: <CAPTjJmp0BQ0y5atoJS5+NK2zt3RQr7G4r=5=XHzGq8SCcXcUYA@mail.gmail.com>
X-CTCH-Spam: Unknown
X-CTCH-RefID: str=0001.0A702F21.6221E366.002A, ss=1, re=0.000, recu=0.000,
reip=0.000, cl=1, cld=1, fgs=0
X-OriginalArrivalTime: 04 Mar 2022 10:03:23.0997 (UTC)
FILETIME=[15DC48D0:01D82FAF]
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
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: <4392817.Tn9u4OIKmF@coyote>
X-Mailman-Original-References: <CALq4Z0-fJk-HOu0ka2kPrOioPYAh3e3zbziwetUDmAAx1U1LMw@mail.gmail.com>
<25121.48093.26762.592197@ixdm.fritz.box>
<CAPTjJmp0BQ0y5atoJS5+NK2zt3RQr7G4r=5=XHzGq8SCcXcUYA@mail.gmail.com>
 by: gene heskett - Fri, 4 Mar 2022 10:01 UTC

On Friday, 4 March 2022 02:18:51 EST Chris Angelico wrote:
> On Fri, 4 Mar 2022 at 18:13, Dieter Maurer <dieter@handshake.de> wrote:
> > Rob Cliffe wrote at 2022-3-4 00:13 +0000:
> > >I find it so hard to remember what `for ... else` means that on the
> > >very few occasions I have used it, I ALWAYS put a comment
> > >alongside/below the `else` to remind myself (and anyone else
> > >unfortunate enough to read my code) what triggers it, e.g.
> > >
> > > for item in search_list:
> > > ...
> > > ... break
> > >
> > > else: # if no item in search_list matched the criteria
> > >
> > >You get the idea.
> > >If I really want to remember what this construct means, I remind
> > >myself that `else` here really means `no break`. Would have been
> > >better if it had been spelt `nobreak` or similar in the first
> > >place.
> >
> > One of my use cases for `for - else` does not involve a `break`:
> > the initialization of the loop variable when the sequence is empty.
> > It is demonstrated by the following transscript:
> >
> > ```pycon
> >
> > >>> for i in range(0):
> > ... pass
> > ...
> >
> > >>> i
> >
> > Traceback (most recent call last):
> > File "<stdin>", line 1, in <module>
> >
> > NameError: name 'i' is not defined
> >
> > >>> for i in range(0):
> > ... pass
> > ... else: i = None
> > ...
> >
> > >>> i
> >
> > ```
> >
> > For this use case, `else` is perfectly named.
>
> What's the point of this? Why not just put "i = None" after the loop?
>
That makes the logic work, but who then cleans up the trash on the stack.
Thats a memory leak.

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

Cheers, Gene Heskett.
--
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.
- Louis D. Brandeis

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor