Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

UNIX is many things to many people, but it's never been everything to anybody.


devel / comp.lang.python / Re: Negative subscripts

SubjectAuthor
o Re: Negative subscriptsChris Angelico

1
Re: Negative subscripts

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

  copy mid

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

  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: Negative subscripts
Date: Tue, 30 Nov 2021 06:50:00 +1100
Lines: 60
Message-ID: <mailman.53.1638215413.9869.python-list@python.org>
References: <96741f1a-72b3-6551-39b3-f1862c5a80b8@chagford.com>
<ba4a976c-5829-03ac-2e3f-cf670f00c3f7@DancesWithMice.info>
<1c37f528-250c-85b5-5e98-2ccde350438b@chagford.com>
<c21483f1-9d14-968d-7d75-aa1ca3f90cc0@DancesWithMice.info>
<CAPTjJmoHcEB5GJnEpmq-B18qz6eX2u8_qLhGkSKv0kr-V7cYcw@mail.gmail.com>
<90500dcf-fb29-4923-6004-d16e338068b8@DancesWithMice.info>
<CAPTjJmpGCKnUsheCft8pyoyF9RECvw9WxH_WjVFzBwqxp0tgCA@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 9askgaD91JeNL7Q0YluTKQA9nwdcRo3In9I5SncIhCkQ==
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=MS3W0nNX;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.004
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '(which': 0.04; 'is.':
0.05; 'coder': 0.07; 'explicitly': 0.07; 'loop': 0.07;
'underlying': 0.07; '27,': 0.09; 'angelico': 0.09; 'depend': 0.09;
'expression': 0.09; "hasn't": 0.09; "list's": 0.09; 'though.':
0.09; 'unlike': 0.09; 'url:reference': 0.09; '(eg': 0.16;
'assignments': 0.16; 'chrisa': 0.16; 'evaluated': 0.16;
'evaluating': 0.16; 'executed': 0.16; 'from:addr:rosuav': 0.16;
'from:name:chris angelico': 0.16; 'interpreter': 0.16; 'iterable':
0.16; 'looping': 0.16; 'object,': 0.16; 'present,': 0.16;
'slicing': 0.16; 'text)': 0.16; 'yield': 0.16; 'wrote:': 0.16;
'tue,': 0.19; 'to:addr:python-list': 0.20; 'application.': 0.22;
'sat,': 0.22; '(and': 0.25; 'seems': 0.26; 'else': 0.27; 'chris':
0.28; 'it,': 0.29; 'wondering': 0.31; "doesn't": 0.32; 'empty':
0.32; 'python-list': 0.32; 'said,': 0.32; 'message-
id:@mail.gmail.com': 0.32; 'unless': 0.32; "i'm": 0.33;
'particular': 0.33; 'header:In-Reply-To:1': 0.34;
'received:google.com': 0.34; 'item': 0.35; 'yes,': 0.35;
'from:addr:gmail.com': 0.35; 'request': 0.35; 'target': 0.36;
'those': 0.36; 'using': 0.37; 'received:209.85': 0.37;
'received:209': 0.39; 'list': 0.39; 'evaluation': 0.39; '(see':
0.40; 'should': 0.40; 'in,': 0.60; "there's": 0.61; 'gives': 0.62;
'true': 0.63; 'once': 0.63; 'definition': 0.64; 'upon': 0.64;
'items': 0.68; 'during': 0.69; 'further': 0.69; 'order': 0.69;
'generator': 0.69; 'sequence': 0.69; 'terms': 0.70; 'rules': 0.70;
'2021': 0.71; 'suite': 0.71; "you'll": 0.73; 'features': 0.75;
'produces': 0.76; 'life': 0.77; 'returned': 0.81; 'eventually':
0.84; 'further,': 0.84; 'proceed,': 0.84; 'thus,': 0.84;
'amended': 0.91; 'anticipated': 0.91
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=KotYXkHJQkQTdtxRMEhy0cuLPZ2FAVLkgi1APIWs/Rg=;
b=MS3W0nNXeErmBW8C1H4b7Bw1plrCpZ8MpIIs1um37veCxZN3yQJQFpIKUTa9E7S5KG
McljVnMjGAkE/ukhMHxWl5WL+yXa/cD38RCZYXl5R92IvwWEpVtLnIUE5VfHJgacQJ/J
25Zn2GQ+9gBUef35YRoisjP61ZrjvNgRiMb9+U3rIi8VPMayVj4C8KjT32dXMT1ubTim
Ogvyxp1CNorl8HkwB3+NrGJZ/5pt/F5FR1LC6rr+esrxL6xnSEeAvC/q0hrLaZmiFFvq
RU8lr8MPOt3egRhZw9S7m5GiZjsA0LsGYiNKhDMRGpH1klvH32QoYwksg55tBaddNCUR
yCQg==
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=KotYXkHJQkQTdtxRMEhy0cuLPZ2FAVLkgi1APIWs/Rg=;
b=p62EqBJUBR6JyNexedOhwzRwVVwScFn7jbh9fzygstl2UZfOIXVHTtsbjTxiZomlXu
ll8Ds0p+zI0vpZL5eZueHiO00a80jemg3xaiS2LasyOKyX+fip/6ubqKP3GYbfXcgMIo
ta+wjmnEOo8IaSbPvzmDCItQhQjvWn2i3AGWc1pS/DqhB2tJbLDOfcqADHlw2Qu/u5Yv
tbt1/w+PsPHNNz7qUledneooDxrH+TpmdeCEjPV/2q1tbck8/9XaJnLuC8jG3LHLNl//
HbUMW8B7/75pXARH2YPyaibj7ai/zsK5XiJJpxJIo/V51mHBbuGzSplWPDbdmt4My9f6
gFYw==
X-Gm-Message-State: AOAM530fIde2cJHKQZQeRiE9LDzO6BmcLA6vaqkzuxvJ8AKlnK3Epyj3
Rp/JroJwwowUoiMNa/mtiUBtr0KjUMOLbDMn5jBmaj5u
X-Google-Smtp-Source: ABdhPJwBRE6aJtfZWXQtHFy6xXbE3lfOMVXtfjuPieVN3jn87fY4kUYygZOT3LD5KSTzDobEz+h6xWVVLjfqczYbPqk=
X-Received: by 2002:adf:f6cf:: with SMTP id y15mr35475129wrp.56.1638215411447;
Mon, 29 Nov 2021 11:50:11 -0800 (PST)
In-Reply-To: <90500dcf-fb29-4923-6004-d16e338068b8@DancesWithMice.info>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.37
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: <CAPTjJmpGCKnUsheCft8pyoyF9RECvw9WxH_WjVFzBwqxp0tgCA@mail.gmail.com>
X-Mailman-Original-References: <96741f1a-72b3-6551-39b3-f1862c5a80b8@chagford.com>
<ba4a976c-5829-03ac-2e3f-cf670f00c3f7@DancesWithMice.info>
<1c37f528-250c-85b5-5e98-2ccde350438b@chagford.com>
<c21483f1-9d14-968d-7d75-aa1ca3f90cc0@DancesWithMice.info>
<CAPTjJmoHcEB5GJnEpmq-B18qz6eX2u8_qLhGkSKv0kr-V7cYcw@mail.gmail.com>
<90500dcf-fb29-4923-6004-d16e338068b8@DancesWithMice.info>
 by: Chris Angelico - Mon, 29 Nov 2021 19:50 UTC

On Tue, Nov 30, 2021 at 6:45 AM dn via Python-list
<python-list@python.org> wrote:
>
>
>
> On 27/11/2021 21.23, Chris Angelico wrote:
> > On Sat, Nov 27, 2021 at 7:21 PM dn via Python-list
> > <python-list@python.org> wrote:
> >> The expression list is evaluated once; it should yield an iterable
> >> object. An iterator is created for the result of the expression_list.
> >> The suite is then executed once for each item provided by the iterator,
> >> in the order returned by the iterator. Each item in turn is assigned to
> >> the target list using the standard rules for assignments (see Assignment
> >> statements), and then the suite is executed. When the items are
> >> exhausted (which is immediately when the sequence is empty or an
> >> iterator raises a StopIteration exception), the suite in the else
> >> clause, if present, is executed, and the loop terminates.
> >> ยป
> >> https://docs.python.org/3/reference/compound_stmts.html#the-for-statement
> >>
> >>
> >> That said, I'm wondering if all is strictly true when the
> >> expression_list is a generator, which by definition features
> >> lazy-execution rather than up-front list production. So, things may
> >> depend upon the full-nature of the application.
> >
> > Yes, it is. Evaluating a generator expression gives you a generator
> > object, which is an iterable.
>
>
> You (and the text) are correct - the expression list is "evaluated once"
> and produces a generator object. For a particular understanding of
> "evaluate".
>
> However, as described, all that has been "evaluated" is a
> generator-object. Unlike (say) a list's iterator, a generator only
> eventually produces a 'list' - and each time the generator is
> called-upon to yield the next value, that value has to be "evaluated",
> ie there's some further evaluation loop-by-loop.
>
> Further, that the values-returned can be amended during the life of the
> generator (in ways anticipated and unanticipated by coder and
> interpreter alike). Thus, it seems that the "list" doesn't actually
> exist, as in, hasn't been "evaluated" as data-values, when the loop is
> enacted.
>
> What has been 'evaluated' are the terms by which the looping will
> proceed, and terminate.
>

That's true of ALL iterators though. If you get a list iterator, and
while you're stepping through it, the underlying list changes, you'll
see those changes. Nothing gets "snapshot" unless you explicitly
request it (eg by slicing the list first).

ChrisA

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor