Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Vulcans do not approve of violence. -- Spock, "Journey to Babel", stardate 3842.4


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.126.1646327928.2329.python-list@python.org>

  copy mid

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

  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: Thu, 3 Mar 2022 16:44:28 +0000
Lines: 51
Message-ID: <mailman.126.1646327928.2329.python-list@python.org>
References: <CALq4Z0-fJk-HOu0ka2kPrOioPYAh3e3zbziwetUDmAAx1U1LMw@mail.gmail.com>
<180be823-a9f6-5e16-e85a-884706a5611f@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 2UJA6CZwP0j3kkOzAT3RBwxaBY3KZS9Sy0N1Qg5i90hQ==
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=uUGsQNWR;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.002
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python?': 0.03; '(which':
0.04; 'parallel': 0.05; 'variable': 0.05; 'e.g.': 0.07; 'loop':
0.07; 'construct': 0.09; 'else:': 0.09; 'received:192.168.1.64':
0.09; 'accepted.': 0.16; 'executed': 0.16; 'flag': 0.16;
'iterable': 0.16; 'iteration': 0.16; 'myself)': 0.16; 'once.':
0.16; 'sensible': 0.16; 'separately': 0.16; 'separately,': 0.16;
'subject:else': 0.16; 'universe,': 0.16; 'wrote:': 0.16; "can't":
0.17; 'uses': 0.19; 'proposals': 0.19; 'to:addr:python-list':
0.20; 'issue': 0.21; "i've": 0.22; 'maybe': 0.22; 'so.': 0.26;
'suggestions': 0.28; 'header:User-Agent:1': 0.30; 'whole': 0.30;
'think': 0.32; "doesn't": 0.32; 'elements': 0.32; 'empty': 0.32;
'retrieve': 0.32; "wouldn't": 0.32; 'zero': 0.32;
'received:192.168.1': 0.32; 'but': 0.32; 'subject:for': 0.33;
'there': 0.33; 'someone': 0.34; 'header:In-Reply-To:1': 0.34;
'trying': 0.35; 'also,': 0.36; 'really': 0.37; 'using': 0.37;
"it's": 0.37; 'received:192.168': 0.37; 'means': 0.38; 'adding':
0.39; 'block': 0.39; 'received:213': 0.40; 'wishes': 0.40; 'want':
0.40; 'try': 0.40; 'best': 0.61; 'here.': 0.61; 'imagine': 0.64;
'your': 0.64; 'now,': 0.67; 'times': 0.69; 'survey': 0.71;
'little': 0.73; 'easy': 0.74; 'behavior:': 0.84; 'rob': 0.84;
'spelling': 0.84; 'body.': 0.91; 'broke': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=btinternet.com;
s=btmx201904; t=1646325868;
bh=gpjOeNklXqUS7tNkaKGRJJLPkAV98Hnlp9GpwloHHAY=;
h=Message-ID:Date:MIME-Version:Subject:To:References:From:In-Reply-To;
b=uUGsQNWRZS4oquNzI0flo8w9aASZV58oe9ZP0MJJxISOQ6vV2mXUsSrqOyKEVV64sMjEYl7gVk5xgaw2CLJUa4S6+1VAXIvh4Sh+cctpowcL0kuS2lD8GHYfh3Ig1RIaZ49EuOX7VJ4n9ekXKC1zPrBTdztooY52l4dwGlh3BGUUuOZ/RbJg8bdahTFQa27CoP/I6HxUrPT/WjdsR05juW6xBo3GMBXERvgdyNtxPZIPmwxY+4i+tSSYPtgpEYQ7ZF6jheex5vsSNbBxz3eLONEz3JQKoxaHiZ9lRa3nIPs1O/qFqIwpX8r+mQaeyqHEKsGLTZaBFzSAtdTS71YktQ==
Authentication-Results: btinternet.com;
auth=pass (PLAIN) smtp.auth=rob.cliffe@btinternet.com;
bimi=skipped
X-SNCR-Rigid: 6139417C17EC14B6
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: gggruggvucftvghtrhhoucdtuddrgedvvddruddtiedgleduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuueftkffvkffujffvgffngfevqffopdfqfgfvnecuuegrihhlohhuthemuceftddunecunecujfgurhepkfffgggfuffvfhfhjggtgfesthekredttdefjeenucfhrhhomheptfhosgcuvehlihhffhgvuceorhhosgdrtghlihhffhgvsegsthhinhhtvghrnhgvthdrtghomheqnecuggftrfgrthhtvghrnhepvdetudfhtefgveegieffleelvdeugfeikeevveehudetgfevieejfedtteevtdegnecukfhppeekiedrudejfedruddvgedrvdelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehhvghloheplgduledvrdduieekrddurdeigegnpdhinhgvthepkeeirddujeefrdduvdegrddvledpmhgrihhlfhhrohhmpehrohgsrdgtlhhifhhfvgessghtihhnthgvrhhnvghtrdgtohhmpdhnsggprhgtphhtthhopedvpdhrtghpthhtoheptghomhhpuhhtvghrmhgrshhtvghrfeeitdesghhmrghilhdrtghomhdprhgtphhtthhopehphihthhhonhdqlhhishhtsehphihthhhonhdrohhrgh
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: <CALq4Z0-fJk-HOu0ka2kPrOioPYAh3e3zbziwetUDmAAx1U1LMw@mail.gmail.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: <180be823-a9f6-5e16-e85a-884706a5611f@btinternet.com>
X-Mailman-Original-References: <CALq4Z0-fJk-HOu0ka2kPrOioPYAh3e3zbziwetUDmAAx1U1LMw@mail.gmail.com>
 by: Rob Cliffe - Thu, 3 Mar 2022 16:44 UTC

It has occasional uses (I THINK I've used it myself) but spelling it
`else` is very confusing.  So there have been proposals for an
alternative spelling, e.g. `nobreak`.
There have also been suggestions for adding other suites after `for', e.g.
    if the loop WAS exited with `break`
    if the loop was executed zero times
but these have not been accepted.
Best wishes
Rob Cliffe

On 03/03/2022 13:24, computermaster360 wrote:
> I want to make a little survey here.
>
> Do you find the for-else construct useful? Have you used it in
> practice? Do you even know how it works, or that there is such a thing
> in Python?
>
> I have used it maybe once. My issue with this construct is that
> calling the second block `else` doesn't make sense; a much more
> sensible name would be `then`.
>
> Now, imagine a parallel universe, where the for-else construct would
> have a different behavior:
>
> for elem in iterable:
> process(elem)
> else:
> # executed only when the iterable was initially empty
> print('Nothing to process')
>
> Wouldn't this be more natural? I think so. Also, I face this case much
> more often than having detect whether I broke out of a loop early
> (which is what the current for-else construct is for).
>
> Now someone may argue that it's easy to check whether the iterable is
> empty beforehand. But is it really? What if it's an iterator?
> Then one would have to resort to using a flag variable and set it in
> each iteration of the loop. An ugly alternative would be trying to
> retrieve
> the first element of the iterable separately, in a try block before
> the for-loop, to find out whether the iterable is empty. This would of
> course
> require making an iterator of the iterable first (since we can't be
> sure it is already an iterator), and then -- if there are any elements
> -- processing
> the first element separately before the for-loop, which means
> duplicating the loop body. You can see the whole thing gets really
> ugly really quickly...
>
> What are your thoughts? Do you agree? Or am I just not Dutch enough...?

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor