Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Old mail has arrived.


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

SubjectAuthor
o Re: Behavior of the for-else constructRob Cliffe

1
Re: Behavior of the for-else construct

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: rob.cli...@btinternet.com (Rob Cliffe)
Newsgroups: comp.lang.python
Subject: Re: Behavior of the for-else construct
Date: Fri, 4 Mar 2022 22:22:30 +0000
Lines: 22
Message-ID: <mailman.175.1646432559.2329.python-list@python.org>
References: <CALq4Z0-fJk-HOu0ka2kPrOioPYAh3e3zbziwetUDmAAx1U1LMw@mail.gmail.com>
<YiFCPlGC+2aRIR0K@shallowsky.com>
<21739669.459456.1646348879560@mail.yahoo.com>
<e3544242-cd54-05d3-2101-5b9fedc1c13e@btinternet.com>
<25121.48093.26762.592197@ixdm.fritz.box>
<1277767760.379444.1646412189311@mail.yahoo.com>
<CAPTjJmpGph9woqQGnkoE9=auFw49UqYMr3OxbhK24LytUgdyEA@mail.gmail.com>
<1957563644.11129.1646427163819@mail.yahoo.com>
<d95a8e00-c846-596e-11af-6d587cbfa249@btinternet.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de J4o7/DrgOe/2mAbWFpV2JQKGrrSpHt1MYco5VoY0p2Sw==
Return-Path: <rob.cliffe@btinternet.com>
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=btinternet.com header.i=@btinternet.com header.b=KCS2NOLG;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.008
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'looks': 0.02; 'variable':
0.05; 'loop': 0.07; 'else:': 0.09; 'fails': 0.09; 'readable':
0.09; 'received:192.168.1.64': 0.09; 'skip:` 10': 0.09; 'avi':
0.16; 'general.': 0.16; 'gross': 0.16; 'idea.': 0.16; 'print(x)':
0.16; 'semantics': 0.16; 'sounds': 0.16; 'subject:else': 0.16;
'toy,': 0.16; 'variable,': 0.16; 'wrote:': 0.16; 'calls': 0.19;
'to:addr:python-list': 0.20; 'exception': 0.22; 'maybe': 0.22;
'run': 0.23; 'else': 0.27; 'local': 0.27; 'bit': 0.27; 'function':
0.27; 'done': 0.28; 'header:User-Agent:1': 0.30; 'attempt': 0.31;
'approach': 0.31; 'wondering': 0.31; 'empty': 0.32; 'python-list':
0.32; 'received:192.168.1': 0.32; 'but': 0.32; 'subject:for':
0.33; 'path': 0.33; 'mean': 0.34; 'header:In-Reply-To:1': 0.34;
'trying': 0.35; 'handling': 0.35; 'yes,': 0.35; 'people': 0.36;
'using': 0.37; "it's": 0.37; 'received:192.168': 0.37; 'use':
0.39; 'neither': 0.39; 'received:213': 0.40; 'wishes': 0.40;
'both': 0.40; 'something': 0.40; 'try': 0.40; 'including': 0.60;
'best': 0.61; 'copy': 0.63; 'your': 0.64; 'similar': 0.65; 'well':
0.65; 'back': 0.67; 'right': 0.68; 'accurately': 0.69; 'compared':
0.71; 'content': 0.72; 'plus': 0.73; 'leads': 0.81; '20:52,':
0.84; 'rob': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=btinternet.com;
s=btmx201904; t=1646432553;
bh=zupe26xJQxXtiaRJJpVF7VN85aX6AhO+PEza730aWeQ=;
h=Message-ID:Date:MIME-Version:Subject:To:References:From:In-Reply-To;
b=KCS2NOLGFBnY8Mq4fwvMNpzXlgi+wEtMsyx42oqFFVwFcgn+wBhLlr3L5lXBU4eX/T94CCtYxfqKbboy6R+mWCyj/N09QdrEP1qcE6tUtQ/ZRqPUxSdFaG0HTpcgAI1QwHUd1LFw52G1l81w6AC7A3AmpI5190Tas9Y8QkByCO/GgqI9wNjnSwulhZmZrtBwuWiXGtHJ7L8Lxk3MzYONaiIhuNCteZGPjNJxsBA5fyNkAp1MAbK12EWNDBdYGTm25t9X8nkj5ZrByc6Q2VPjqxMzTLTIpyyGAvBtKbabzmPSVD9vDbEXXdcfesZKnifC3afkeHTiixZRKC177n0+Hw==
Authentication-Results: btinternet.com;
auth=pass (PLAIN) smtp.auth=rob.cliffe@btinternet.com;
bimi=skipped
X-SNCR-Rigid: 61A69BAC0BB48513
X-Originating-IP: [86.173.124.29]
X-OWM-Source-IP: 86.173.124.29 (GB)
X-OWM-Env-Sender: rob.cliffe@btinternet.com
X-VadeSecure-score: verdict=clean score=0/300, class=clean
X-RazorGate-Vade: gggruggvucftvghtrhhoucdtuddrgedvvddruddtkedgudeiudcutefuodetggdotefrodftvfcurfhrohhfihhlvgemuceutffkvffkuffjvffgnffgvefqofdpqfgfvfenuceurghilhhouhhtmecufedtudenucenucfjughrpefkffggfgfuvfhfhfgjtgfgsehtkeertddtfeejnecuhfhrohhmpeftohgsucevlhhifhhfvgcuoehrohgsrdgtlhhifhhfvgessghtihhnthgvrhhnvghtrdgtohhmqeenucggtffrrghtthgvrhhnpedvteduhfetgfevgeeiffelledvuefgieekveevhedutefgveeijeeftdetvedtgeenucfkphepkeeirddujeefrdduvdegrddvleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhephhgvlhhopegludelvddrudeikedruddrieegngdpihhnvghtpeekiedrudejfedruddvgedrvdelpdhmrghilhhfrhhomheprhhosgdrtghlihhffhgvsegsthhinhhtvghrnhgvthdrtghomhdpnhgspghrtghpthhtohepuddprhgtphhtthhopehphihthhhonhdqlhhishhtsehphihthhhonhdrohhrgh
X-RazorGate-Vade-Verdict: clean 0
X-RazorGate-Vade-Classification: clean
X-SNCR-hdrdom: btinternet.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Content-Language: en-GB
In-Reply-To: <1957563644.11129.1646427163819@mail.yahoo.com>
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: <d95a8e00-c846-596e-11af-6d587cbfa249@btinternet.com>
X-Mailman-Original-References: <CALq4Z0-fJk-HOu0ka2kPrOioPYAh3e3zbziwetUDmAAx1U1LMw@mail.gmail.com>
<YiFCPlGC+2aRIR0K@shallowsky.com>
<21739669.459456.1646348879560@mail.yahoo.com>
<e3544242-cd54-05d3-2101-5b9fedc1c13e@btinternet.com>
<25121.48093.26762.592197@ixdm.fritz.box>
<1277767760.379444.1646412189311@mail.yahoo.com>
<CAPTjJmpGph9woqQGnkoE9=auFw49UqYMr3OxbhK24LytUgdyEA@mail.gmail.com>
<1957563644.11129.1646427163819@mail.yahoo.com>
 by: Rob Cliffe - Fri, 4 Mar 2022 22:22 UTC

On 04/03/2022 20:52, Avi Gross via Python-list wrote:
>
> I have an observation about exception handling in general. Some people use exceptions, including ones they create and throw, for a similar idea. You might for example try to use an exception if your first attempt fails that specifies trying the next attempt. In my example of the PATH variable, you might use something like calling a function and giving it what you are looking for as well as a local copy of the PATH variable content and the exception would be to call the function again with the first component of PATH removed until you fail with an empty PATH. Yes, this is similar to just having a recursive function.
That sounds neither readable nor efficient compared with using split()
plus a loop.  Maybe you mean this to be a toy, unrealistic example?
> So the example tossed at us looks a bit more like this and it does run the ELSE not because the loop is not done but because the loop never calls a break:
>
> for x in range(0):
> print(x)
> else:
> print("Finally finished!")
This would be more readable with a `zeroiterations` keyword, which
accurately describes both the semantics and the intent.
> Which leads me right back to wondering why the sentinel approach is so bad!
>
>
It's not that bad, but it's more convenient and readable if it can be
avoided.
Best wishes
Rob Cliffe


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

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor