Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"I never let my schooling get in the way of my education." -- Mark Twain


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

SubjectAuthor
o Re: Behavior of the for-else constructAvi Gross

1
Re: Behavior of the for-else construct

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: avigr...@verizon.net (Avi Gross)
Newsgroups: comp.lang.python
Subject: Re: Behavior of the for-else construct
Date: Fri, 4 Mar 2022 00:38:22 +0000 (UTC)
Lines: 167
Message-ID: <mailman.139.1646354309.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>
Reply-To: Avi Gross <avigross@verizon.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de YoWV+EenEW10gcvXNxwNsgkhb/y03ikRo5RIuzjGy/Dg==
Return-Path: <avigross@verizon.net>
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=verizon.net header.i=@verizon.net header.b=foRYg5Ds;
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; 'readable': 0.09;
'speak.': 0.09; 'theory': 0.09; 'treated': 0.09; 'typically':
0.09; 'way?': 0.09; 'writes:': 0.09; 'url:mailman': 0.15;
'alphabets': 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; '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; 'to:name:python-list@python.org': 0.24; '(and':
0.25; 'skip:- 10': 0.25; 'url-ip:188.166.95.178/32': 0.25; 'url-
ip:188.166.95/24': 0.25; 'url:listinfo': 0.25; 'programming':
0.25; 'url-ip:188.166/16': 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; 'sense': 0.28; 'thinking': 0.28;
'it,': 0.29; 'code,': 0.31; 'comment': 0.31; 'putting': 0.31;
'url-ip:188/8': 0.31; 'wondering': 0.31; 'think': 0.32; "doesn't":
0.32; 'question': 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; '....': 0.76;
'combination': 0.76; 'sponsored': 0.76; 'reply': 0.77; 'sent:':
0.78; 'major': 0.78; 'header:Reply-To:1': 0.79; '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; 'received:74.6.133.124': 0.84;
'received:sonic313-14.consmr.mail.bf2.yahoo.com': 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=verizon.net; s=a2048;
t=1646354306; bh=S4cz/mZOs+O0WAzZ8eRwChZMEhqVf0MONqofUeHOBkI=;
h=Date:From:Reply-To:To:In-Reply-To:References:Subject:From:Subject:Reply-To;
b=foRYg5DsVeZFh8/eG3BXcuGmBtOigS7hExSmNtw2FNQj3mzhKJejg5a9lh3KxulSDzzTunm5Zlfjjpc1a8nCYmVlzKjbzQQgSkL0qoGWSplMjmKAsn1Arymxrs3msYeSvy1cKV6ryu9PJ83SoQSoKorKsh5FgiRK60EmS3mr9YfHGMB79Dq7gONOOU7fGwEFdNIBjLBDUbyDmJ0lysOfns11PJUmwoJdmipu3a415P37MfzuGd7h8/lUluJqpmw5db4MBR/m5+oOwUm1M60JZKY2AbVuj2I97iSIz/JWNn2njUHZxsuaqtSR59Pht8CmwUdAK6D0ULFsRcKicJuDuw==
X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo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QP2EOL5hE730Z3ofMdbtk5XzkW9oY4Kh2SsAL_3eezExTXoLs
xJE9XHga53M3JB97O5ir8T6HbciHe4LeOjaOOivfkIs6Y2Se7EahIdxC1ich.6k9DAD_2IaD2Cjq
mu5ESxgQ4.._JQvtRqgJRK3tlWae6Y8Ri3G8BP5DUxtKNNU5H4.ZA7Un0AmDPKS3HIiFyxJ6O53Z
BMdZOB2YN0Sd0NN6DghV6smGZrU0.TAYyfRQ5FBODwZU5ckZtKt6oBYxQwDaH7FjPIW9ZnL61gd9
1Vn5YY8AV.Fth7NTmjfFkhZnWPvq5g6ay5y1ajsgz8lKhT8t1TXfsaKsqmWo7k1HLRTYE6jeVqBl
MRfXzFpyP5NUFGq_lJsbSNTz0yoLRCl4NDWPtUWhxE_misx_cgLLYaklOew0926EJu2cX1vH6Imt
lzXnlQypAVQTcDo0SctMCYTcaI0a8NhNfPIBjxKsRErzOfYUHDykll3t1RV_ACGxJfS59sOD5vSz
vTdrdhHpFS0LCmA1WESFf4SDNss1Ap1CBxHtmvcLM1atjnm5PM9Hf5_K4PwiR.T2ZTeK0ybOV8Dh
F2r8S2YL6yEsW7_XfxzprUT7Syw--
X-Sonic-MF: <avigross@verizon.net>
In-Reply-To: <e3544242-cd54-05d3-2101-5b9fedc1c13e@btinternet.com>
X-Mailer: WebService/1.1.19724 aolwebmail
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: <621325684.471007.1646354302946@mail.yahoo.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>
 by: Avi Gross - Fri, 4 Mar 2022 00:38 UTC

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.

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!

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?

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

--
https://mail.python.org/mailman/listinfo/python-list

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor