Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

To the systems programmer, users and applications serve only to provide a test load.


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

SubjectAuthor
o Re: Behavior of the for-else constructGrant Edwards

1
Re: Behavior of the for-else construct

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: grant.b....@gmail.com (Grant Edwards)
Newsgroups: comp.lang.python
Subject: Re: Behavior of the for-else construct
Date: Thu, 03 Mar 2022 08:58:46 -0800 (PST)
Lines: 34
Message-ID: <mailman.123.1646326729.2329.python-list@python.org>
References: <CALq4Z0-fJk-HOu0ka2kPrOioPYAh3e3zbziwetUDmAAx1U1LMw@mail.gmail.com>
<6220f3c6.1c69fb81.e7cdd.716c@mx.google.com>
X-Trace: news.uni-berlin.de 9XM2KtsXXI/aP1d5uKfcqwSybMYxIQuOhRevxTSswINg==
Return-Path: <grant.b.edwards@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=UNan0xlC;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.008
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; '(which': 0.04; 'parallel':
0.05; 'loop': 0.07; 'construct': 0.09; 'else:': 0.09; 'yes.':
0.09; '_not_': 0.16; 'executed': 0.16;
'from:addr:grant.b.edwards': 0.16; 'from:name:grant edwards':
0.16; 'iterable': 0.16; 'subject:else': 0.16; 'universe,': 0.16;
'wrote:': 0.16; 'to:addr:python-list': 0.20; 'so.': 0.26; 'else':
0.27; 'header:User-Agent:1': 0.30; 'think': 0.32; 'empty': 0.32;
"wouldn't": 0.32; 'but': 0.32; 'subject:for': 0.33;
'received:google.com': 0.34; 'received:209.85.166': 0.35;
'from:addr:gmail.com': 0.35; 'also,': 0.36; "it's": 0.37;
'received:209.85': 0.37; 'received:209': 0.39; 'use': 0.39;
'should': 0.40; 'skip:o 10': 0.61; 'feel': 0.63; 'imagine': 0.64;
'look': 0.65; 'now,': 0.67; 'behavior:': 0.84; 'broke': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=message-id:date:from:subject:references:user-agent:to;
bh=cq6qHvxJjcEj1sg23kWudpjKK7qK0nRTW3isobihYEc=;
b=UNan0xlCWyv0RjWUs8H3hbAsVN4+O1SE0Oy+QMgzGHl41RNYuhw3PfT6n6+Q7xOC/X
OZ/E1pUZ9u7N4d9oO0VrE7la6GSU5YSqWZ2XrNYFTyMJhg6lmt65m5p6GSt/HHb26dX+
ZzjDmG2SoxCix62hohfNnFUAPKbwjbL1WdIQ8OdPuZDFtlHG7giEFbrZBpMSMxlHwhp4
CKTA7PLznOo3VibyfHaxhseXCtE8J4hoKl6oh+sqUdYLlKCGzXkqNooug8pqmMZjrQdO
ssXZsWhTkwBwag2qPjIs5Bq2j3NovOIuZU/asQgCmipHLpCqFQnvSs5eWlfN68wTwr3w
76pA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:message-id:date:from:subject:references
:user-agent:to;
bh=cq6qHvxJjcEj1sg23kWudpjKK7qK0nRTW3isobihYEc=;
b=7F/nEJ5CW8SF5BXFe+5f5ro0DA2Nmx+gEUXh8BfMECUFC2aqkr6/EF5VlCYOXKPBSB
QVUn0CK+QcH7YbhqOxoOQElL7Oj4XkYHYUKDIM/VqAdJJiLqwnh+9u0YE7WAn3p3jTjb
eBzzU5C3njEyYyENCGJeE+t0yw/jBUt00ES+DU9N/pTjzLFooaskhhuSu2D/58gjkBwa
9uIvFGmJh1ClOJ1VlqYBPpJjIzPWR+Qte8FLaklhYEY3ZKJS2NOBkXFuVOarAEvGzkvf
znuzcRjKiHU4O3FyXsXEDkJXHXna6NJaIXbwoLfbJeHp8xOFd2ka89WuPowcq46a8aNZ
kosw==
X-Gm-Message-State: AOAM532R7gkTrufrVW6qv50hB81AomOvqVkWo3FLWSUck85vZEg0OXCP
A4I9ulkecLC+xDe4moWyMPkzWskon9w=
X-Google-Smtp-Source: ABdhPJz44yWChVKCl6MbmGgEjy9+KunS1gK3TgNqkMBovSQbyTUKkXPXO232YQ60J+hgltB/vb0mWw==
X-Received: by 2002:a05:6e02:1947:b0:2c1:7096:8c8a with SMTP id
x7-20020a056e02194700b002c170968c8amr32936965ilu.309.1646326726866;
Thu, 03 Mar 2022 08:58:46 -0800 (PST)
User-Agent: slrn/1.0.3 (Linux)
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: <6220f3c6.1c69fb81.e7cdd.716c@mx.google.com>
X-Mailman-Original-References: <CALq4Z0-fJk-HOu0ka2kPrOioPYAh3e3zbziwetUDmAAx1U1LMw@mail.gmail.com>
 by: Grant Edwards - Thu, 3 Mar 2022 16:58 UTC

On 2022-03-03, computermaster360 <computermaster360@gmail.com> wrote:

> Do you find the for-else construct useful?

Yes.

> Have you used it in practice?

Yes.

I don't use it often, but I do use it occasionally.

However, I always have to look it up the docs to confirm the logic. I
always feel like the else should be executed if the for loop does
_not_ terminate naturally, but it's the opposite.

> Now, imagine a parallel universe, where the for-else construct would
> have a different behavior:
>
> for elem in iterable:
> process(elem)
> else:
> # executed only when the iterable was initially empty
> print('Nothing to process')
>
> Wouldn't this be more natural?

That also make sense.

> I think so. Also, I face this case much more often than having
> detect whether I broke out of a loop early (which is what the
> current for-else construct is for).

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor