Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Send lawyers, guns and money..." -- Lyrics from a Warren Zevon song


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

SubjectAuthor
o Re: Behavior of the for-else constructCameron Simpson

1
Re: Behavior of the for-else construct

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: cs...@cskk.id.au (Cameron Simpson)
Newsgroups: comp.lang.python
Subject: Re: Behavior of the for-else construct
Date: Sun, 6 Mar 2022 09:18:23 +1100
Lines: 38
Message-ID: <mailman.198.1646518723.2329.python-list@python.org>
References: <1659671269.122157.1646502520833@mail.yahoo.com>
<YiPhr8kPmRKdArE7@cskk.homeip.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: news.uni-berlin.de dd8kvl1WFkW9irzNPzMXvQl08LxtZpexhbS8dTsCAAXQ==
Return-Path: <cameron@cskk.id.au>
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.033
X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; ':-)': 0.09; 'else:': 0.09;
'cheers,': 0.11; 'avi': 0.16; 'but...': 0.16; 'cameron': 0.16;
'from:addr:cs': 0.16; 'from:addr:cskk.id.au': 0.16;
'from:name:cameron simpson': 0.16; 'gross': 0.16; 'interruption':
0.16; 'message-id:@cskk.homeip.net': 0.16; 'received:10.10': 0.16;
'simpson': 0.16; 'subject:else': 0.16; 'wrote:': 0.16; 'reached':
0.17; 'instead': 0.17; 'to:addr:python-list': 0.20; 'to:name
:python-list@python.org': 0.24; 'cover': 0.26; 'suggest': 0.28;
'header:User-Agent:1': 0.30; 'seem': 0.31; 'but': 0.32;
'subject:for': 0.33; 'someone': 0.34; 'header:In-Reply-To:1':
0.34; 'count': 0.36; 'using': 0.37; 'could': 0.38; 'break': 0.39;
'still': 0.40; 'match': 0.40; 'above': 0.62; 'skip:b 10': 0.63;
'pass': 0.64; 'wish': 0.66; 'received:userid': 0.66;
'header:Received:6': 0.67; 'and,': 0.69; 'implemented': 0.76;
'received:119': 0.84; 'statement.': 0.84; 'variation': 0.91;
'implied': 0.93
X-RG-Spam: Unknown
X-RazorGate-Vade: gggruggvucftvghtrhhoucdtuddrgedvvddruddutddgudeitdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfupfevtfgpvffgnffuvffttedpqfgfvfenuceurghilhhouhhtmecugedttdenucenucfjughrpeffhffvuffkgggtuggjfghfsehttdertddtredvnecuhfhrohhmpeevrghmvghrohhnucfuihhmphhsohhnuceotghssegtshhkkhdrihgurdgruheqnecuggftrfgrthhtvghrnhepleevfeeghfeggfehuddvgfehhfffjeegvdeuiefhgeelgeekfeffiefguddtveehnecukfhppeduudelrdduvddrvddukedrudelfeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhephhgvlhhopegsohhrghdrtghskhhkrdhhohhmvghiphdrnhgvthdpihhnvghtpeduudelrdduvddrvddukedrudelfedpmhgrihhlfhhrohhmpegtrghmvghrohhnsegtshhkkhdrihgurdgruhdpnhgspghrtghpthhtohepuddprhgtphhtthhopehphihthhhonhdqlhhishhtsehphihthhhonhdrohhrgh
X-RazorGate-Vade-Verdict: clean 0
X-RazorGate-Vade-Classification: clean
X-RG-VS-CLASS: clean
X-Authentication-Info: Submitted using ID cskk@bigpond.com
Mail-Followup-To: "python-list@python.org" <python-list@python.org>
Content-Disposition: inline
In-Reply-To: <1659671269.122157.1646502520833@mail.yahoo.com>
User-Agent: Mutt/2.2.1 (2022-02-19)
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: <YiPhr8kPmRKdArE7@cskk.homeip.net>
X-Mailman-Original-References: <1659671269.122157.1646502520833@mail.yahoo.com>
 by: Cameron Simpson - Sat, 5 Mar 2022 22:18 UTC

On 05Mar2022 17:48, Avi Gross <avigross@verizon.net> wrote:
>Since we still seem to be dreaming, I wonder when someone will suggest using some variation of the new match statement.

Ugh :-)

But...

What if break were implemented with an exception, like StopIteration but
for interruption instead of stop? And for-loops were an implied
try/except:

for ...
except BrokenIteration: # <-- implied
pass

and you could go:

for ...
except BrokenIteration:
... a break occurred
else:
... a break did not occur

and, indeed,

for ...
except BrokenIteration:
... a break occurred
except StopIteration as stopped:
print("I did", stopped.count, "iterations")
else:
# not reached because of the "except StopIteration" above
... a break did not occur

if we wanted to cover off the count iterations wish item.

Cheers,
Cameron Simpson <cs@cskk.id.au>

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor