Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

After 14 non-maintainer releases, I'm the S-Lang non-maintainer. -- Ray Dassen


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

SubjectAuthor
o Re: Behavior of the for-else constructChris Angelico

1
Re: Behavior of the for-else construct

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ros...@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: Behavior of the for-else construct
Date: Fri, 4 Mar 2022 11:34:07 +1100
Lines: 98
Message-ID: <mailman.138.1646354060.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>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de 7XBbd0GGrf0SjwliB8x3JQiodN7zq4OreX0vRYWzdhZQ==
Return-Path: <rosuav@gmail.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=gmail.com header.i=@gmail.com header.b=hVZI8/pu;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.009
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; '2022': 0.05; 'fairly':
0.05; 'else.': 0.07; 'mar': 0.07; 'used.': 0.07; 'wrong.': 0.07;
'"just': 0.09; 'else:': 0.09; 'emacs': 0.09; 'it)': 0.09;
'language,': 0.09; 'operators': 0.09; 'supported': 0.15; 'syntax':
0.15; '[1]:': 0.16; 'arbitrary': 0.16; 'avi': 0.16; 'chrisa':
0.16; 'constructs.': 0.16; 'feature.': 0.16; 'from:addr:rosuav':
0.16; 'from:name:chris angelico': 0.16; 'gross': 0.16; 'idea.':
0.16; 'instead.': 0.16; 'intuitive': 0.16; 'mean,': 0.16;
'order?': 0.16; 'programmer.': 0.16; 'recall': 0.16; 'reminds':
0.16; 'safe".': 0.16; 'sentences,': 0.16; 'subject:else': 0.16;
'triggered': 0.16; 'tuple': 0.16; 'typing': 0.16; 'yield': 0.16;
'wrote:': 0.16; 'instead': 0.17; "can't": 0.17; 'implement': 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; 'version': 0.23; 'idea': 0.24; 'to:name:python-
list@python.org': 0.24; 'python,': 0.25; 'anyone': 0.25; 'seems':
0.26; 'binary': 0.26; 'do,': 0.26; "isn't": 0.27; 'leave': 0.27;
'else': 0.27; 'bit': 0.27; 'function': 0.27; 'it,': 0.29;
'wondering': 0.31; 'think': 0.32; 'context': 0.32; 'fine.': 0.32;
'language.': 0.32; 'programmers': 0.32; 'python-list': 0.32;
'returning': 0.32; 'words,': 0.32; 'message-id:@mail.gmail.com':
0.32; 'but': 0.32; "i'm": 0.33; 'subject:for': 0.33; 'there':
0.33; 'particular': 0.33; 'someone': 0.34; 'able': 0.34; 'same':
0.34; 'core': 0.34; 'mean': 0.34; 'skip:" 20': 0.34; 'work.':
0.34; 'header:In-Reply-To:1': 0.34; 'received:google.com': 0.34;
'running': 0.34; 'meaning': 0.35; 'from:addr:gmail.com': 0.35;
'files': 0.36; 'functions': 0.36; 'people': 0.36; 'change': 0.36;
'those': 0.36; 'really': 0.37; 'using': 0.37; "it's": 0.37;
'received:209.85': 0.37; 'hard': 0.37; 'way': 0.38; 'could': 0.38;
'read': 0.38; 'received:209': 0.39; 'two': 0.39; 'quite': 0.39;
'adding': 0.39; 'use': 0.39; 'search': 0.61; 'remember': 0.61;
"there's": 0.61; 'above': 0.62; 'forward': 0.62; 'basis': 0.62;
'ever': 0.63; 'simply': 0.63; 'everything': 0.63; 'imagine': 0.64;
'similar': 0.65; 'tool': 0.65; 'now,': 0.67; 'types': 0.67;
'back': 0.67; '[1]': 0.67; 'heard': 0.67; 'items': 0.68;
'perfectly': 0.69; 'little': 0.73; 'easy': 0.74; 'tools': 0.74;
'hearing': 0.75; 'features': 0.75; 'features.': 0.76; 'sponsored':
0.76; 'supposed': 0.76; 'points': 0.84; 'absolutely': 0.84;
'bind': 0.84; 'desperately': 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; 'heads': 0.91;
'scared': 0.91; 'cut': 0.95
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to
:content-transfer-encoding;
bh=q4LONqOe0MweT0uT7o6KVAXmA6adsQLXxnmv/TGFa94=;
b=hVZI8/puEofkQUGtfCFjTNlRUyCutwwPLFbRUzrQ8f2J1QR1IuQgOPI6fJDQUAVqPM
Me3Yuig66GhL51wP2kxZrEkGUyzVrJzNwlvGKPhAYumQl14N4IeJzNFZXLq3H3WeZVG/
Yx6i6sgBJM1qDqpE8gTO+2AVtWNvAcxJ9nyDtJ/tNvUwUj8HXJ959ujVEHHgvEu0jFkT
Wo/7xWlB+wk6gfVB8lQI0rciXUTsHP5VDbwEPx8/gcWks+GYGbVpCqz7Fj3S5OsCvF9/
KUdg0an7bB9QwG+vmhJ1hTa3RrqTJ/YQJUIDhAlQrcMmfKjpPn5NaZeI65+Vz5W51dmV
Rglg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to:content-transfer-encoding;
bh=q4LONqOe0MweT0uT7o6KVAXmA6adsQLXxnmv/TGFa94=;
b=B4dQCCBu3AJF5zvG5qk81V3GRYQvdTwQ4zGHEkZng294ARphc1Us5E6JkIIHU0TUgE
qeFrtqwhYJ3Vz12AjLvCBzihqxrZpbYH8jEPJCi8ryDjlyCagq+8XEnLqC8igp8NoWRc
YTW5GVH3zfjsaYwWjkYh24xQw4VynsFb/BKJgoZ63cEYJ8xKUUBVsNMrTZs2w/nJCp3a
5lrvSw8wnaI6V59mGJVgCTafYhtiuadi7FmGfXhVDjaxu6M4+4jqlJWhq4TLVOuyZgpU
ztaoCu3dC2olgfpYaQH/GqA9hmjtqt4HPEg+9eF2J+airuq5edxOfRlKFOngnSiNDhTB
/6mQ==
X-Gm-Message-State: AOAM533wpnIWJ0o2Oc3EpM8tZRdfk4vQJPeTaZirATJ2Psy7nQ3SV8YR
FBkR28/EEt9auOV/uMLceQ2rVRM7KfMVYIYYJffTMGj4
X-Google-Smtp-Source: ABdhPJw2Hn2IAolomaOFUZwz+b2/GWhH7iOTTjMr9IbdccIHTgKELhOk8Nkf/3/EUARidBpVzs0lIhp/Qi05f164WKw=
X-Received: by 2002:a5d:6047:0:b0:1ea:9a8a:9542 with SMTP id
j7-20020a5d6047000000b001ea9a8a9542mr27582238wrt.243.1646354058394; Thu, 03
Mar 2022 16:34:18 -0800 (PST)
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: <CAPTjJmoXyHF_N1E2KFZ+YZmZ8+zm4E_Pra_hbXLHWuNs1XtiBQ@mail.gmail.com>
X-Mailman-Original-References: <CALq4Z0-fJk-HOu0ka2kPrOioPYAh3e3zbziwetUDmAAx1U1LMw@mail.gmail.com>
<YiFCPlGC+2aRIR0K@shallowsky.com>
<21739669.459456.1646348879560@mail.yahoo.com>
 by: Chris Angelico - Fri, 4 Mar 2022 00:34 UTC

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

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor