Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Somebody's terminal is dropping bits. I found a pile of them over in the corner.


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

SubjectAuthor
o Re: Negative subscriptsChris Angelico

1
Re: Negative subscripts

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: ros...@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: Negative subscripts
Date: Fri, 26 Nov 2021 22:24:16 +1100
Lines: 18
Message-ID: <mailman.22.1637925869.9869.python-list@python.org>
References: <96741f1a-72b3-6551-39b3-f1862c5a80b8@chagford.com>
<ee198109-7f76-f987-8f41-7f18080de51e@btinternet.com>
<CAPTjJmp6DCt230qTyoGtZkv9ofHoq0NUCZWz9s8Esdsj=O4VUQ@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de KAvNDhKlBDT6zc/QbJBG+wpd5NpyGSluqozX/zAILZMQ==
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=RUhqDocx;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.013
X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'argument': 0.04; '26,':
0.07; 'unlike': 0.09; '"don\'t': 0.16; '"or': 0.16; 'approach,':
0.16; 'chrisa': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris
angelico': 0.16; 'iterate': 0.16; 'received:209.85.221.54': 0.16;
'received:mail-wr1-f54.google.com': 0.16; 'wrote:': 0.16; 'to:addr
:python-list': 0.20; 'fri,': 0.22; 'list,': 0.24; "i'd": 0.24;
'else': 0.27; 'whole': 0.30; 'negative': 0.32; 'python-list':
0.32; 'zero': 0.32; 'message-id:@mail.gmail.com': 0.32; 'header
:In-Reply-To:1': 0.34; 'received:google.com': 0.34; 'item': 0.35;
'from:addr:gmail.com': 0.35; 'received:209.85': 0.37; 'could':
0.38; 'means': 0.38; 'received:209': 0.39; 'this,': 0.39;
'handle': 0.39; 'use': 0.39; 'still': 0.40; 'important.': 0.69;
'2021': 0.71; 'here"': 0.84; 'none"': 0.84; 'rob': 0.84
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;
bh=7esu9WKqZAB/k1IMOEIyQTHSvqtL8MajuTs9b63AOl0=;
b=RUhqDocxxuOuKELf3JYcorTIoJFww3/C6Yjs1Mws+vLQnxj9Ymn/majynNHF65kohy
LxYtDGD312KZNTouSzYa4kmUvlIQBcdjV8L8DFLYpuf5vrFpzix3+hmEfPBxa70yXYkx
P8R0UaTC7Ees3j0VlR395xzdtC0h0+kg6nVEB4CiH53J9UsXKfHUtNVk41CfMPik5z2G
D8QpJ5tMEX2/LY/HtzAz9xcfdba0kypq43issaGum4/H4ELm+THOLIKz+Ts+5862MSPD
x5lvJTeB+fsL+L1+J4vf+RM8XWr3JADCBRWkzqdflCeEz8mapNzTFZE48cud3b+FRVFB
a0Ww==
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;
bh=7esu9WKqZAB/k1IMOEIyQTHSvqtL8MajuTs9b63AOl0=;
b=osRKl7dDSgtNoc0fo0r6YXNXqfBXFBALsn2F5OGg6sbxPIXnR+B5hjalP6NZzhVK/x
iAxrqCTn2lRkxlSwKJDccJR1hLRt0knnWg9nvvc6XZp6DMeaXAFCrt7E2rWQBkT20Z90
XMiVVnqBpNnmQEdmmqev36zV8f0yg93I27+XGfaP418SBl3eSR8ci0ezjTZRRZQi10rX
Dra7kVxi4I6Qav1289rM8nHu6VlRZQh8mW9Rq1YSVs0IDIMD6zBghCSfIZ+bOScPa00C
aOHm8Villc3MUN+Mj1lPq8YRVDsk6fUCThHD9gLRZUI0feMsgbO+SnguZPLB7g/PMg+C
A11A==
X-Gm-Message-State: AOAM533M/HIgzelzAht7dWLvFpa+4BdlHaQCHIo5MPnCuu1Rpz+vhaXa
mXKcmvqXUA9q6qWauijB9p78oLTVytRySIS5LvpTzcNR
X-Google-Smtp-Source: ABdhPJyG7j6jAHxS1l+Gg9VTJsPlGC8XUHU7zadsy4qo+sxSAH/X1CIhyBmB0hcPtcJPAPNlMfJVuTIUZq1lSC8ygYo=
X-Received: by 2002:a05:6000:15c7:: with SMTP id
y7mr13602723wry.424.1637925867686;
Fri, 26 Nov 2021 03:24:27 -0800 (PST)
In-Reply-To: <ee198109-7f76-f987-8f41-7f18080de51e@btinternet.com>
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: <CAPTjJmp6DCt230qTyoGtZkv9ofHoq0NUCZWz9s8Esdsj=O4VUQ@mail.gmail.com>
X-Mailman-Original-References: <96741f1a-72b3-6551-39b3-f1862c5a80b8@chagford.com>
<ee198109-7f76-f987-8f41-7f18080de51e@btinternet.com>
 by: Chris Angelico - Fri, 26 Nov 2021 11:24 UTC

On Fri, Nov 26, 2021 at 10:11 PM Rob Cliffe via Python-list
<python-list@python.org> wrote:
> or, perhaps simplest, you could do
>
> for item in x[:-y or None]: # a value of None for a slice argument means
> "don't slice here"
> [do stuff]
>

This is the one I'd recommend. If you're negating a slice like this,
just add "or None" to handle negative zero as the other end of the
list.

Be aware that this will still slice even if you're going to use the
whole list, unlike the "x[-y] if y else x" approach, which will
iterate over the original list. That might be important.

ChrisA

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor