Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"All these black people are screwing up my democracy." - Ian Smith


devel / comp.lang.python / Re: for -- else: what was the motivation?

SubjectAuthor
o Re: for -- else: what was the motivation?Dan Stromberg

1
Re: for -- else: what was the motivation?

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!aioe.org!feeder1.feed.usenet.farm!feed.usenet.farm!news-out.netnews.com!news.alt.net!fdc2.netnews.com!fu-berlin.de!uni-berlin.de!not-for-mail
From: drsali...@gmail.com (Dan Stromberg)
Newsgroups: comp.lang.python
Subject: Re: for -- else: what was the motivation?
Date: Fri, 7 Oct 2022 21:13:17 -0700
Lines: 46
Message-ID: <mailman.544.1665202411.20444.python-list@python.org>
References: <433a0cd3-48b1-6aae-7bd0-f13828002947@declassed.art>
<CAGGBd_ow7WRnqbKnS1SxCFgQAzkSJi2iGAKUphrZb57xiN2mcw@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de Yx5PA6jkncYtzIoX2YbktALMYbcq49ep2R7aLBGJxgvg==
Return-Path: <drsalists@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=n5HgNaaV;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.009
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; '2022': 0.05; 'run.': 0.05;
'loop': 0.07; 'cc:addr:python-list': 0.09; 'else:': 0.09;
'url:mailman': 0.15; 'cc:name:python list': 0.16; 'executed':
0.16; 'expectation': 0.16; 'from:addr:drsalists': 0.16;
'from:name:dan stromberg': 0.16; 'question,': 0.16; 'something.':
0.16; 'subject: -- ': 0.16; 'subject:else': 0.16; 'subject:what':
0.16; 'wrote:': 0.16; 'python': 0.16; 'cc:addr:python.org': 0.20;
'fri,': 0.22; 'url-ip:188.166.95.178/32': 0.25; 'url-
ip:188.166.95/24': 0.25; 'url:listinfo': 0.25; 'cc:2**0': 0.25;
'url-ip:188.166/16': 0.25; 'anyone': 0.25; 'else': 0.27; 'email
addr:python.org&gt;': 0.28; 'url-ip:188/8': 0.31; 'assume': 0.32;
'python-list': 0.32; 'message-id:@mail.gmail.com': 0.32; 'but':
0.32; 'subject:for': 0.33; 'same': 0.34; 'header:In-Reply-To:1':
0.34; 'received:google.com': 0.34; 'following': 0.35;
'from:addr:gmail.com': 0.35; 'main': 0.37; 'received:209.85':
0.37; 'received:209': 0.39; 'remember': 0.61; 'mental': 0.62;
'miss': 0.62; 'ever': 0.63; 'down': 0.64; 'produce': 0.65;
'years': 0.65; 'body': 0.67; 'caught': 0.67; 'pieces': 0.70;
'clause': 0.84; 'email name:&lt;python-list': 0.84;
'\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=cc:to:subject:message-id:date:from:in-reply-to:references
:mime-version:from:to:cc:subject:date:message-id:reply-to;
bh=LILOGjg0tzI/ZgzMMKn12Ch2Go0KNQ3Slb9es0SnmxE=;
b=n5HgNaaVqisutXmQHNQAw/PLLNgwwiCFiyIAHC4vCxPAPk8vl4GaPBxhpHez5jOM8v
piO9xb9o7w+bS/tXQMO07cxHL4xcC5fdC0fSJ2Xag0j2xhai+DQxCiLbyYJcaswPi9/f
cWTR0CG79VK6rEBbjMXgP3mpz4B3sDjqcoELs209CxTkuV9EAXY8C8tPgf11+6R81OCz
myqPcscVorD8jzje+pXDqi5Kh6sTq0Pje1PCd0w6nrnsK0Gd6Y7Xwc+EqPWH/dWEWEdY
F1GGVnGew7jZRRbPjs70P2nhqoL77ueWiSJg+P2FHCWIlnVS327xrGyRzL97SHmelyGm
4xOQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=cc:to:subject:message-id:date:from:in-reply-to:references
:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id
:reply-to;
bh=LILOGjg0tzI/ZgzMMKn12Ch2Go0KNQ3Slb9es0SnmxE=;
b=7dD+PklX+nEVlYKXYgCbPMoHcA17Kkbm3nu736JkKfYrxwMuCpTs9fDepyWvWvLOXu
vZ+FiLuDx4BzFD4GCZrBUc6EPTj//CyeVd67h+jdoa6xV3jBdRQczVJPYnzBxg61t5lB
po9Dzun3ooe2ziTXyJMWy63H/DOZ3ykwnFYEQbCTD5Jq0EemyLaM8YkxPPJbA4gfPald
GjBOd5ESpoeOwCXSJ2DdvCKL3V7CURJ0kZfqV9xhrNUqHwluCbjH2Ze7tfsFB1QluR1k
DfVOfCbOlJU9q8/sBEwFAsmxz6KetsxuIHYs+YE+iKL03veEQQVgT6iJia/b3omsWzfa
Qv6Q==
X-Gm-Message-State: ACrzQf2Ut6mKxCNKv8hRkcWsMqo5sAY3yfZyK3dAr5a2m+w/j3FhILpg
9hYgoFjPNTfbpvcbj5iRVfjb729Yx8XVS5RRzWHbYwRp
X-Google-Smtp-Source: AMsMyM4IzV1V6J7ah10iERfyERy6fpXrFM4hceyD6jh729JmknNYNd/ou/dWR5dSlSNep70SOHZOzFiro7mNNavUPYg=
X-Received: by 2002:a05:6512:3a86:b0:4a2:5058:b500 with SMTP id
q6-20020a0565123a8600b004a25058b500mr2803143lfu.369.1665202409521; Fri, 07
Oct 2022 21:13:29 -0700 (PDT)
In-Reply-To: <433a0cd3-48b1-6aae-7bd0-f13828002947@declassed.art>
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
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: <CAGGBd_ow7WRnqbKnS1SxCFgQAzkSJi2iGAKUphrZb57xiN2mcw@mail.gmail.com>
X-Mailman-Original-References: <433a0cd3-48b1-6aae-7bd0-f13828002947@declassed.art>
 by: Dan Stromberg - Sat, 8 Oct 2022 04:13 UTC

The else is executed if you don't "break" out of the loop early.

It cuts down on boolean flags.

On Fri, Oct 7, 2022 at 8:40 PM Axy via Python-list <python-list@python.org>
wrote:

> Hi there,
>
> this is rather a philosophical question, but I assume I miss something.
> I don't remember I ever used else clause for years I was with python and
> my expectation was it executed only if the the main body was never run.
> Ha-ha! I was caught by this mental trap.
>
> So, seriously, why they needed else if the following pieces produce same
> result? Does anyone know or remember their motivation?
>
> Just curious.
>
> Axy.
>
> print('--- with else')
>
>
> for i in [1,2,3]:
> print(i)
> else:
> print(4)
>
> for i in []:
> print(i)
> else:
> print(5)
>
> print('--- without else')
>
> for i in [1,2,3]:
> print(i)
> print(4)
>
> for i in []:
> print(i)
> print(5)
> --
> https://mail.python.org/mailman/listinfo/python-list
>

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor