Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Matter cannot be created or destroyed, nor can it be returned without a receipt.


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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!news.szaf.org!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 01:08:08 +0000 (UTC)
Lines: 169
Message-ID: <mailman.142.1646356097.2329.python-list@python.org>
References: <CALq4Z0-fJk-HOu0ka2kPrOioPYAh3e3zbziwetUDmAAx1U1LMw@mail.gmail.com>
<YiFCPlGC+2aRIR0K@shallowsky.com>
<21739669.459456.1646348879560@mail.yahoo.com>
<CAPTjJmoXyHF_N1E2KFZ+YZmZ8+zm4E_Pra_hbXLHWuNs1XtiBQ@mail.gmail.com>
<1277831092.475364.1646356088655@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 qLYkSflM4gF4rCkkW4X4tAeOOz/AvMFI93ZhlLQiYVVg==
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=LVQLJUu+;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '2022': 0.05; 'fairly':
0.05; 'math': 0.05; 'variable': 0.05; 'else.': 0.07; 'mar': 0.07;
'partial': 0.07; 'underlying': 0.07; 'used.': 0.07; 'wrong.':
0.07; '"just': 0.09; 'angelico': 0.09; 'better,': 0.09;
'construct': 0.09; 'else:': 0.09; 'emacs': 0.09; 'expansion':
0.09; 'it)': 0.09; 'language,': 0.09; 'meant': 0.09; 'namespace':
0.09; 'operators': 0.09; 'url:mailman': 0.15; 'supported': 0.15;
'syntax': 0.15; '[1]:': 0.16; 'apl': 0.16; 'arbitrary': 0.16;
'avi': 0.16; 'chrisa': 0.16; 'constructs.': 0.16; 'dots.': 0.16;
'encounter': 0.16; 'epsilon': 0.16; 'feature.': 0.16; 'fourth':
0.16; 'frustration': 0.16; 'gross': 0.16; 'idea.': 0.16;
'incompatible': 0.16; 'instead.': 0.16; 'intuitive': 0.16;
'letters.': 0.16; 'mean,': 0.16; 'next,': 0.16; 'order?': 0.16;
'places,': 0.16; 'programmer.': 0.16; 'recall': 0.16; 'reminds':
0.16; 'reuse': 0.16; 'safe".': 0.16; 'sentences,': 0.16; 'signs,':
0.16; 'stuck': 0.16; 'subject:else': 0.16; 'symbol': 0.16;
'triggered': 0.16; 'tuple': 0.16; 'typing': 0.16; 'understand.':
0.16; 'using.': 0.16; 'ways.': 0.16; 'yield': 0.16; 'wrote:':
0.16; 'python': 0.16; 'larger': 0.17; '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; "i've": 0.22; 'languages':
0.22; 'advanced': 0.22; 'fri,': 0.22; 'problem,': 0.22; 'way.':
0.22; 'version': 0.23; 'code': 0.23; 'idea': 0.24; 'to:name
:python-list@python.org': 0.24; 'anything': 0.25; 'skip:- 10':
0.25; 'url-ip:188.166.95.178/32': 0.25; 'url-ip:188.166.95/24':
0.25; 'python,': 0.25; 'saying': 0.25; 'url:listinfo': 0.25; 'url-
ip:188.166/16': 0.25; 'anyone': 0.25; 'seems': 0.26; 'behavior':
0.26; 'binary': 0.26; 'classes': 0.26; 'do,': 0.26; 'normally':
0.26; "isn't": 0.27; 'leave': 0.27; 'else': 0.27; 'bit': 0.27;
'function': 0.27; 'done': 0.28; 'chris': 0.28; 'purpose': 0.28;
'ideas': 0.28; 'it,': 0.29; 'url-ip:188/8': 0.31; 'mix': 0.69;
'perfectly': 0.69; 'future': 0.72; 'little': 0.73; 'easy': 0.74;
'tools': 0.74; 'hearing': 0.75; 'features': 0.75; 'features.':
0.76; 'sponsored': 0.76; 'supposed': 0.76; 'yes': 0.76; 'sent:':
0.78; 'header:Reply-To:1': 0.79; 'leads': 0.81; 'points': 0.84;
'(var': 0.84; 'absolutely': 0.84; 'bind': 0.84; 'constraints':
0.84; 'desperately': 0.84; 'drove': 0.84; 'exceptions': 0.84;
'feature,': 0.84; 'incorrect': 0.84; 'macro': 0.84; 'signs': 0.84;
'speaking,': 0.84; 'spelling': 0.84; 'was.': 0.84; 'acknowledge':
0.91; 'greek': 0.91; 'hand.': 0.91; 'heads': 0.91; 'plays': 0.91;
'scared': 0.91; 'tend': 0.91; 'shocked': 0.93; 'cut': 0.95;
'keywords': 0.95
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=verizon.net; s=a2048;
t=1646356093; bh=gmJZ95afUqdc/1jtkZgBXkbdjZb9C2MffLAFjLGxolA=;
h=Date:From:Reply-To:To:In-Reply-To:References:Subject:From:Subject:Reply-To;
b=LVQLJUu+FAkjfegU/ISDyJMtHpwKiXalZ0JP8BwN1Sf15aC6AYj//eRV/Xt+wzfKMhYY/DQp2ys85dgK01yz8SdpQ/kNUmNWRxxpYkSptKdz5ZlKyJSaeQyH0ShijqOgtMINaGwXAm3EpVo0qA2Me9LHQWr4TMLMBQ+N5tHpfePZGQkb87CXDtr4WwZfTxVIkzZJJdAGEgKybk7Vkw7AWlW3kK1xECfMQdrNaTDbSgeQ56Xk2wR4em93yDT0+OUOiCNDEMbVVRzTh0h+zkUQ+fPSoA92Bl1T6t22RjXMhwKNoVi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lSJfj9svGh5R41f
nEZsKcNuMyr88Stc7v7VqABwjZXEFEBNoIRBQxfTrSuXYwpFraJH_lKru_eSdcIYtpjJC7mpq_Nq
wVto5R5yWsBSRVX23HiOYtHk9_hkJnVfCDlwSweSW2dtepYDl7VET_DV34X1UkrCLzYrTDVaaaBQ
0sq8U6tO.3fOuknnJ2AG1mcztgokh9wcxGAXwsl8fuMEQPxc3wr6FdtJMqVzwiQZOZAL59fx0clB
jxX5StmXc9md.iTpNEKWJQuUzUgrX9rHeEy0v4Kww2mRB.KEisnWelIDJHCIjkekmxVNAgtFiKhH
HzVVlEcPU1tFFpP3BwWAqTruJtDoQXkVdehWpIsSSJe9bXdVzlAeY.N4M_IrFtAjlWAj_uE72UM6
G6Cbz7v8s2xRdXyBc_aXOM2dP4alKrV2rSryceKFm.fYEvVc2VYgmr1QDc65LgfZy.NK.dUzf0ax
.iiXRh99pdg7j9pe392TFl8gtGtyFHGpgKBfFifO2WwQKs_WIB2ivV7_4U9pY7pS12VMrj.NpKSJ
9x3_qdf3K998ZJo5TdWV48Kt35mdb4AX3nxIfMLuo0.wKNO9jPfns7Htb30l0Q2wlw0caDHlgFly
jHddK9ivJacaF5Sa03Mqn3s4JEivWp_UrTGmbZfaco1lSl5gMQCyNdAY1RquuCmoxxLnTY5Fmxuz
hZX4.BxpI5uYoHplCykmBgvmSVA--
X-Sonic-MF: <avigross@verizon.net>
In-Reply-To: <CAPTjJmoXyHF_N1E2KFZ+YZmZ8+zm4E_Pra_hbXLHWuNs1XtiBQ@mail.gmail.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: <1277831092.475364.1646356088655@mail.yahoo.com>
X-Mailman-Original-References: <CALq4Z0-fJk-HOu0ka2kPrOioPYAh3e3zbziwetUDmAAx1U1LMw@mail.gmail.com>
<YiFCPlGC+2aRIR0K@shallowsky.com>
<21739669.459456.1646348879560@mail.yahoo.com>
<CAPTjJmoXyHF_N1E2KFZ+YZmZ8+zm4E_Pra_hbXLHWuNs1XtiBQ@mail.gmail.com>
 by: Avi Gross - Fri, 4 Mar 2022 01:08 UTC

Chris,

Much of what I intended is similar to what you say. I am simply saying the existing group of programmers seems to include people who will not see every thing the same way. There is no way to make them all happy and you have other constraints like not suddenly adding new reserved words, so you do the best you can and hope people can get educated.

I have seen lots of otherwise bright people drop out of math classes not because they could not understand the concepts, but because they have trouble handling all the symbols being used, such as Greek letters. Often they get stuck simply because nobody tells them how to pronounce the letter as in epsilon or zeta or aleph. Or consider the many ways various people denote a derivative. For some f'(x) and f''(x) feel right but dy/dx and d^2y/dx^2 (assume since this is plain next, I meant a small superscript 2 representing squared) makes no sense. Others like it the other way and still others like a dot on top of something like an s or two dots. I can mix and match many such representations because I know they are just representations of an underlying thing that I do understand. I have seen people then get stuck at partial derivatives which use a new symbol instead of the d, whose name they do not know like ∂

Teaching APL also drove some students crazy with all the overprinted symbols.

So, yes, using ELSE in what seems to them like multiple and incompatible ways can lead to frustration but is rather unavoidable.

Which leads to a point you misunderstood. I was saying R reserved a namespace of sorts so that adding new keywords could be done safely. Users are not expected to make variable names like %in% so you can write code like if (var %in% listing) and you can even change the definition in a sort of overloading to do something different. YES this can lead to others puzzling over your code. But if you need a new keyword, perhaps you could expand into such a reserved corner of the namespace and avoid having to reuse existing key words in possibly incompatible, or at least for some non-intuitive, ways. It does not need to use percent signs, just some notation users would normally not already be using. I am not here to say R is better, just some ideas are very different and thus many things chosen now are not inevitable. It gives me some flexibility in say calling a function as `[`(args) instead of [args] and rewriting it. Python plays lots of similar games, such as the decorators you like to use. In many places, Python makes it easier for me to do things.

There really are more like three kinds of Programmers. Some see the world one way and some another way and some are switch hitters. The fourth kind tend not to be programmers! The ones who are adaptable and simply acknowledge that a decision has been made and use the functionality as it is done, do best. No need to complain, just adapt. And, of course, you can just not use anything that does not appeal to you but do not be shocked if you encounter code by others who are using it and be ready to understand it enough for the purpose at hand.

If Python was being designed TODAY, I wonder if a larger set of key words would be marked as RESERVED for future expansion including ORELSE and even NEVERTHELESS.

-----Original Message-----
From: Chris Angelico <rosuav@gmail.com>
To: python-list@python.org <python-list@python.org>
Sent: Thu, Mar 3, 2022 7:34 pm
Subject: Re: Behavior of the for-else construct

On Fri, 4 Mar 2022 at 10:09, Avi Gross via Python-list
<python-list@python.org> 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.
>

What I'm hearing is that there are, broadly speaking, two types of
programmers [1]:

1) Those who think about "for-else" as a search tool and perfectly
understand how it behaves
2) Those who have an incorrect idea about what for-else is supposed to
do, don't understand it, and don't like it.

You could easily make a similar point about a lot of other advanced
constructs. Some people don't understand threading, and either dislike
it or are scared of it. Some people never get their heads around
asyncio and the way that yield points work. Some people can't grok
operator precedence, so they parenthesize everything "just to be
safe". And some people dislike exceptions so much that they warp all
their functions into returning a (value,True) or (error,False) tuple
instead. Does this mean that all these features are bad? No.

There's no way to make every feature perfectly intuitive to every
programmer. Those features are still incredibly useful to the
programmers that DO use them.

Maybe, with hindsight, for-finally would have been a slightly better
spelling than for-else. Who knows. But people simply need to
understand it, just like people need to understand how binary
floating-point works, and claiming that it's "ambiguous' is simply
wrong. It has one meaning in the language, and then if programmers
have an incorrect expectation, they need to learn (or to not use the
feature, which isn't really a problem, it's just not taking advantage
of it).

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

I don't know what you mean by "extendable", but if you mean that
different people should be able to change the language syntax in
different ways, then absolutely not. When two different files can be
completely different languages based on a few directives, it's
extremely difficult to read.

(Import hooks, and tools like MacroPy, can be used for this sort of
effect. I do not think that we should be using them on a regular basis
to change core syntax.)

> 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 don't know what they'd all mean, but if they were all in the core
language, they would have to be supported in arbitrary combinations.
It's possible to have a "try-except-else-finally" block in Python, for
instance. But if you mean that they should all do what "else" does
now, then this is a terrible idea. One way of spelling it is just
fine.

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

SciTE has a "transpose lines" feature. I use it frequently. But editor
features are quite different from language features.

ChrisA

[1] Something tells me I've heard this before

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

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor