Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Old age and treachery will beat youth and skill every time." -- a coffee cup


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

  copy mid

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

  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 00:13:00 +0000
Lines: 74
Message-ID: <mailman.137.1646352784.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>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de GWP/mYx/aph3HftVJ6oIyAg8Qp7IhEEKyjnQk8EFh+Sw==
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=j3xf/DwL;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.013
X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'python?': 0.03; '2022':
0.05; 'fairly': 0.05; 'e.g.': 0.07; 'else.': 0.07; 'exit': 0.07;
'loop': 0.07; 'mar': 0.07; 'used.': 0.07; 'construct': 0.09;
'else:': 0.09; 'emacs': 0.09; 'ended': 0.09; 'it)': 0.09;
'operators': 0.09; 'readable': 0.09; 'received:192.168.1.64':
0.09; 'writes:': 0.09; 'avi': 0.16; 'does,': 0.16; 'flow.': 0.16;
'gross': 0.16; 'idea.': 0.16; 'instead.': 0.16; 'matched': 0.16;
'order?': 0.16; 'recall': 0.16; 'reminds': 0.16; 'sentences,':
0.16; 'subject:else': 0.16; 'triggered': 0.16; 'typing': 0.16;
'unfortunate': 0.16; 'wrapper': 0.16; 'wrote:': 0.16; 'instead':
0.17; 'implement': 0.19; 'thu,': 0.19; 'to:addr:python-list':
0.20; 'language': 0.21; 'languages': 0.22; 'version': 0.23;
'code': 0.23; '(and': 0.25; 'skip:- 10': 0.25; 'anyone': 0.25;
'seems': 0.26; 'behavior': 0.26; 'leave': 0.27; 'else': 0.27;
'bit': 0.27; 'function': 0.27; 'sense': 0.28; 'it,': 0.29; 'header
:User-Agent:1': 0.30; 'code,': 0.31; 'comment': 0.31; 'wondering':
0.31; "doesn't": 0.32; 'context': 0.32; 'language.': 0.32;
'python-list': 0.32; 'requests,': 0.32; 'signal': 0.32;
'specified': 0.32; 'words,': 0.32; "wouldn't": 0.32;
'received:192.168.1': 0.32; 'but': 0.32; 'subject:for': 0.33;
'there': 0.33; 'particular': 0.33; 'someone': 0.34; 'same': 0.34;
"didn't": 0.34; 'header:In-Reply-To:1': 0.34; 'running': 0.34;
'item': 0.35; 'people': 0.36; 'really': 0.37; 'hard': 0.37;
'received:192.168': 0.37; 'could': 0.38; 'means': 0.38; 'put':
0.38; 'read': 0.38; 'changes': 0.39; 'quite': 0.39; 'added': 0.39;
'adding': 0.39; 'enough': 0.39; 'use': 0.39; 'break': 0.39;
'still': 0.40; 'difficult': 0.40; 'place.': 0.40; 'received:213':
0.40; 'wants': 0.40; 'both': 0.40; 'something': 0.40; 'want':
0.40; 'should': 0.40; 'remember': 0.61; 'here.': 0.61; 'above':
0.62; 'from:': 0.62; 'to:': 0.62; 'forward': 0.62; 'here': 0.62;
'ever': 0.63; 'simply': 0.63; 'once': 0.63; 'imagine': 0.64;
're:': 0.64; 'your': 0.64; 'similar': 0.65; 'look': 0.65;
'worked': 0.67; 'back': 0.67; 'caught': 0.67; 'items': 0.68;
'conditions': 0.70; 'survey': 0.71; 'little': 0.73; 'easy': 0.74;
'non': 0.75; 'hearing': 0.75; 'sponsored': 0.76; 'sent:': 0.78;
'up,': 0.84; 'bind': 0.84; 'code)': 0.84; 'desperately': 0.84;
'entered': 0.84; 'implies': 0.84; 'macro': 0.84; 'means,': 0.84;
'remind': 0.84; 'rob': 0.84; 'signals': 0.84; 'signs': 0.84;
'was.': 0.84; 'expensive': 0.91; 'mind,': 0.93; 'cut': 0.95
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=btinternet.com;
s=btmx201904; t=1646352783;
bh=ao6wt5lGLkg+eIoU6oqOSNWL0mhqEUDEW2g49BVhiCo=;
h=Message-ID:Date:MIME-Version:Subject:To:References:From:In-Reply-To;
b=j3xf/DwLAPNUkGRHy6xy4DEWbxN5iJ3Qvvl1lWOHYYPxH8o1FJMerrTyZnWpMXTuyAEk9vdWcVBieqktyFcHc6M5Pj1nN8DRIazZoKYJTLvk4fd/NofS0EN0msTnUdhvOegUBytfOPko2ZbGVuOxbyki60R30s5Zh71kYBwAbmBiApOLKUHa1iC1VleaROX/a/27QIL1tXNZEdFxYHCZ81qx+g4b/i1obB2+CGFo0HS2b+YZRmeGlup/vafNC7oq5ADaMbUzF9r6qlRzCR9/F8na9kR+uvY0sdwcogCtkgKb57QHHGqoSWgWt+cVElWGxlWfCU27Gwyqxb7WAFiFsQ==
Authentication-Results: btinternet.com;
auth=pass (PLAIN) smtp.auth=rob.cliffe@btinternet.com;
bimi=skipped
X-SNCR-Rigid: 613A901C172A1ABB
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: gggruggvucftvghtrhhoucdtuddrgedvvddruddtjedgudelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuueftkffvkffujffvgffngfevqffopdfqfgfvnecuuegrihhlohhuthemuceftddunecunecujfgurhepkfffgggfuffvfhfhjggtgfesthekredttdefjeenucfhrhhomheptfhosgcuvehlihhffhgvuceorhhosgdrtghlihhffhgvsegsthhinhhtvghrnhgvthdrtghomheqnecuggftrfgrthhtvghrnhepvdetudfhtefgveegieffleelvdeugfeikeevveehudetgfevieejfedtteevtdegnecukfhppeekiedrudejfedruddvgedrvdelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehhvghloheplgduledvrdduieekrddurdeigegnpdhinhgvthepkeeirddujeefrdduvdegrddvledpmhgrihhlfhhrohhmpehrohgsrdgtlhhifhhfvgessghtihhnthgvrhhnvghtrdgtohhmpdhnsggprhgtphhtthhopedupdhrtghpthhtohepphihthhhohhnqdhlihhsthesphihthhhohhnrdhorhhg
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: <21739669.459456.1646348879560@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: <e3544242-cd54-05d3-2101-5b9fedc1c13e@btinternet.com>
X-Mailman-Original-References: <CALq4Z0-fJk-HOu0ka2kPrOioPYAh3e3zbziwetUDmAAx1U1LMw@mail.gmail.com>
<YiFCPlGC+2aRIR0K@shallowsky.com>
<21739669.459456.1646348879560@mail.yahoo.com>
 by: Rob Cliffe - Fri, 4 Mar 2022 00:13 UTC

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.
Rob Cliffe

On 03/03/2022 23:07, Avi Gross via Python-list wrote:
> The drumbeat I keep hearing is that some people hear/see the same word as implying something else. ELSE is ambiguous in the context it is used.
>
> And naturally, since nobody desperately wants to use non-reserved keywords, nobody seems ready to use a word like INSTEAD instead.
>
> Ideally, a language should be extendable and some languages like R allow you to place all kinds of things inside percent signs to make new operators like %*% or %PIPE% ...
>
> Just because some feature may be wanted is not a good reason to overly complicate a language. Can you imagine how hard it would be both to implement and read something like:
>
> ...
> ELSE:
> ...
> OK:
> ...
> FINALLY:
> ...
> ULTIMATELY:
> ...
>
> What if multiple of things like the above example need to be triggered in some particular order?
>
> I have to wonder if some new form of wrapper might have made as much sense as in you wrap your loop in something that sets up and traps various signals that are then produced under conditions specified such as the loop not being entered as the starting condition is sort of null, or an exit due to a break or simply because the code itself throws that signal to be caught ...
>
> This reminds me a bit of how some programs add so much functionality because someone thought of it without wondering if anyone (including the ones who sponsored it) would ever want to use it or remember it is there or how. I recall how a version of emacs had a transpose-letter function so after typing "teh" you could hit control-t and a little mock LISP macro would go back and co a cut and go forward and do a paste and leave the cursor where it was. That was sometimes useful, but often just as easy to backspace and retype. But I recall gleefully adding a transpose for words, sentences, paragraphs and was going to add more but I was running out of keystrokes to bind them to and besides it can be fairly easy to select items and yank them and move to where you want them and replace them.
>
> To make changes in a language is sometimes really expensive but also dangerous. A "free" language must be added to sparingly and with so many requests, perhaps only a few non bug-fixes can seriously be considered.
>
>
>
> -----Original Message-----
> From: Akkana Peck <akkana@shallowsky.com>
> To: python-list@python.org
> Sent: Thu, Mar 3, 2022 5:33 pm
> Subject: Re: Behavior of the for-else construct
>
> computermaster360 writes:
>> I want to make a little survey here.
>>
>> Do you find the for-else construct useful?
> No.
>
>> Have you used it in practice?
> Once or twice, but ended up removing it, see below.
>
>> Do you even know how it works, or that there is such a thing in Python?
> I always have to look it up, because to my mind, "else" implies
> it does something quite different from what it actually does.
>
> Which means that even if I worked hard at memorizing what it does,
> so I didn't have to look it up, I still wouldn't use it in code,
> because I want my code to be easily readable (including by future-me).
> for..else makes code difficult to understand by anyone who doesn't
> use for..else frequently: they might be misled into misunderstanding
> the control flow.
>
>         ...Akkana
>

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor