Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Klingon phaser attack from front!!!!! 100% Damage to life support!!!!


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

  copy mid

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

  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 01:41:18 +0000
Lines: 110
Message-ID: <mailman.144.1646358089.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>
<621325684.471007.1646354302946@mail.yahoo.com>
<77101e25-a341-ee34-ab6b-abc60f858430@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 JGcYB33/q3m4vT1IENwBwwsttAI4oaHXUGSX+TNAq1Sw==
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=Ph/RFV9u;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'comments': 0.03;
'python?': 0.03; '(which': 0.04; '2022': 0.05; 'fairly': 0.05;
'e.g.': 0.07; 'else.': 0.07; 'exit': 0.07; 'loop': 0.07; 'mar':
0.07; 'spaces': 0.07; 'used.': 0.07; 'construct': 0.09; 'else:':
0.09; 'emacs': 0.09; 'ended': 0.09; 'identical': 0.09; 'it)':
0.09; 'language,': 0.09; 'operators': 0.09; 'practice.': 0.09;
'readable': 0.09; 'received:192.168.1.64': 0.09; 'speak.': 0.09;
'theory': 0.09; 'treated': 0.09; 'typically': 0.09; 'way?': 0.09;
'writes:': 0.09; 'alphabets': 0.16; 'answer.': 0.16; 'avi': 0.16;
'considered,': 0.16; 'constantly': 0.16; 'construct.': 0.16;
'does,': 0.16; 'extensions': 0.16; 'filenames': 0.16; 'flow.':
0.16; 'gross': 0.16; 'idea.': 0.16; 'instead.': 0.16;
'languages.': 0.16; 'matched': 0.16; 'nested': 0.16; 'odd': 0.16;
'ones.': 0.16; 'order?': 0.16; 'recall': 0.16; 'reminds': 0.16;
'sentences,': 0.16; 'subject:else': 0.16; 'subset': 0.16; 'tends':
0.16; 'triggered': 0.16; 'typing': 0.16; 'unfortunate': 0.16;
'vector': 0.16; 'wrapper': 0.16; 'wrote:': 0.16; 'python': 0.16;
'code.': 0.17; 'instead': 0.17; "can't": 0.17; 'implement': 0.19;
'thu,': 0.19; 'to:addr:python-list': 0.20; 'language': 0.21;
'languages': 0.22; 'maybe': 0.22; 'version': 0.23; 'code': 0.23;
'command': 0.23; '(and': 0.25; 'skip:- 10': 0.25; 'programming':
0.25; 'anyone': 0.25; 'seems': 0.26; 'behavior': 0.26; 'suspect':
0.26; 'leave': 0.27; 'else': 0.27; 'bit': 0.27; 'function': 0.27;
'>>>': 0.28; 'sense': 0.28; 'thinking': 0.28; 'it,': 0.29; 'header
:User-Agent:1': 0.30; 'code,': 0.31; 'comment': 0.31; 'putting':
0.31; 'wondering': 0.31; 'think': 0.32; "doesn't": 0.32;
'question': 0.32; 'python-list': 0.32; 'requests,': 0.32;
'signal': 0.32; 'specified': 0.32; 'topic,': 0.32; 'words,': 0.32;
"wouldn't": 0.32; 'items': 0.68; 'deeply': 0.69; 'sequence': 0.69;
'conditions': 0.70; 'front': 0.70; 'rules': 0.70; 'survey': 0.71;
'longer': 0.71; 'free': 0.72; 'little': 0.73; 'deal': 0.73;
'easy': 0.74; 'hundreds': 0.75; 'non': 0.75; 'hearing': 0.75;
'combination': 0.76; 'sponsored': 0.76; 'reply': 0.77; 'sent:':
0.78; 'major': 0.78; 'leads': 0.81; 'left': 0.83; 'up,': 0.84;
'(other': 0.84; 'balanced': 0.84; 'bind': 0.84; 'characters':
0.84; 'code)': 0.84; 'desperately': 0.84; 'entered': 0.84;
'implies': 0.84; 'macro': 0.84; 'means,': 0.84; 'quotes': 0.84;
'remind': 0.84; 'rob': 0.84; 'signals': 0.84; 'signs': 0.84;
'strings': 0.84; 'was.': 0.84; 'weird': 0.84; 'differently': 0.91;
'expensive': 0.91; 'viewed': 0.93; 'mind,': 0.93; 'cut': 0.95;
'keywords': 0.95
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=btinternet.com;
s=btmx201904; t=1646358081;
bh=0x+pceHQuKaAAxZbO6TokHiY20OZN5SyXGIb73MWkvM=;
h=Message-ID:Date:MIME-Version:Subject:To:References:From:In-Reply-To;
b=Ph/RFV9u7xdOe2HyDMMH112mtJ1tWADddobeNSZpzSS7Lzsousfk4UrUcXVloikPY/cSyDxi96cDBu8Drjo3wvRzRFRgPCla7qbuhWwymZQMCaStp0Ka39JY6iq2ZjG3qPy4JxWz41brWf6G4LFz3UT2JY7gQx+isqgAXCv5w39CwPDS1zjbjmxfWhf5VDgAoopVLWgWCto/sYjQoPD0rk1wKLoWj7J82Z3c95MiCS9kl/tOkTxYrLuCLzm/iZPYkg7MwQoDm0ro2JEuFdfMhNk5TdudT2SAXXvJnxTO+gWWo423IXrCV75XzlN5oAGOw4jF5dE+MjH3WVnbsWJeIQ==
Authentication-Results: btinternet.com;
auth=pass (PLAIN) smtp.auth=rob.cliffe@btinternet.com;
bimi=skipped
X-SNCR-Rigid: 613A9124172C703B
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: gggruggvucftvghtrhhoucdtuddrgedvvddruddtjedgfeekucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuueftkffvkffujffvgffngfevqffopdfqfgfvnecuuegrihhlohhuthemuceftddunecunecujfgurhepkfffgggfuffvfhfhjggtgfesthekredttdefjeenucfhrhhomheptfhosgcuvehlihhffhgvuceorhhosgdrtghlihhffhgvsegsthhinhhtvghrnhgvthdrtghomheqnecuggftrfgrthhtvghrnhepvdetudfhtefgveegieffleelvdeugfeikeevveehudetgfevieejfedtteevtdegnecukfhppeekiedrudejfedruddvgedrvdelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehhvghloheplgduledvrdduieekrddurdeigegnpdhinhgvthepkeeirddujeefrdduvdegrddvledpmhgrihhlfhhrohhmpehrohgsrdgtlhhifhhfvgessghtihhnthgvrhhnvghtrdgtohhmpdhnsggprhgtphhtthhopedupdhrtghpthhtohepphihthhhohhnqdhlihhsthesphihthhhohhnrdhorhhg
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: <621325684.471007.1646354302946@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: <77101e25-a341-ee34-ab6b-abc60f858430@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>
<621325684.471007.1646354302946@mail.yahoo.com>
 by: Rob Cliffe - Fri, 4 Mar 2022 01:41 UTC

On 04/03/2022 00:38, Avi Gross via Python-list wrote:
> Rob,
>
> I regularly code with lots of comments like the one you describe, or mark the end of a region that started on an earlier screen such as a deeply nested construct.
So do I (and not just in Python).  It's good practice.
>
> I have had problems though when I have shared such code and the recipient strips my comments and then later wants me to make changes or even just explain it! My reply tends to be unprintable as in, well, never mind!
Quite justified.  But why not make changes to/explain from *your*
version, not his?
>
> This leads to a question I constantly ask. If you were free to design a brand new language now, what would you do different that existing languages have had to deal with the hard way?
That's such a big question that I can't give an adequate answer.
>
> I recall when filenames and extensions had a limited number of characters allowed and embedded spaces were verboten. This regularity made lots of code possible but then some bright people insisted on allowing spaces and you can no longer easily do things like expand *.c into a long line of text and then unambiguously work on one file name at a time. You can often now create a name like "was file1.c and now is file2.c" and it seems acceptable. Yes, you can work around things and get a vector or list of strings and not a command line of text and all things considered, people can get as much or more work done.
>
> I have seen major struggles to get other character sets into languages. Any new language typically should have this built in from scratch and should consider adding non-ASCII characters into the mix. Mathematicians often use lots of weird braces/brackets as an example while normal programs are limited to [{( and maybe < and their counterparts. This leads to odd Python behavior (other languages too) where symbols are re-used ad nauseam. { can mean set or dictionary or simply some other way to group code.
>
> So I would love to see some key that allows you to do something like L* to mean the combination is a left bracket and should be treated as the beginning of a sequence expected to end in R* or perhaps *R. That would allow many other symbols to be viewed as balanced entities. Think of how Python expanded using single and double quotes (which arguably might work better if balanced this way) to sometimes using triple quotes to putting letters like "b" or "f" in front to make it a special kind of string.
>
> But I suspect programming might just get harder for those who would not appreciate a language that used (many) hundreds of symbols.
+1.  Just remembering how to type them all would be a burden.
> I do work in many alphabets and many of them pronounce and use letters that look familiar in very different ways and sound them differently and invent new ones. Every time I learn another human language, I have to both incorporate the new symbols and rules and also segregate them a bit from identical or similar things in the languages I already speak. It can be quite a chore. But still, I suspect many people are already familiar with symbols such as from set Theory such as subset and superset that could be used as another pair of parentheses of some type Having a way to enter them using keyboards is a challenge.
>
> Back to the topic, I was thinking wickedly of a way to extend the FOR loop with existing keywords while sounding a tad ominous is not with an ELSE but a FOR ... OR ELSE ...
>
>
> -----Original Message-----
> From: Rob Cliffe via Python-list <python-list@python.org>
> To: python-list@python.org
> Sent: Thu, Mar 3, 2022 7:13 pm
> Subject: Re: Behavior of the for-else construct
>
>
> 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