Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Keep emotionally active. Cater to your favorite neurosis.


comp / comp.lang.python / Re: Two python issues

SubjectAuthor
o Re: Two python issuesJason Friedman

1
Subject: Re: Two python issues
From: Jason Friedman
Newsgroups: comp.lang.python
Date: Tue, 5 Nov 2024 21:08 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: jsf80238@gmail.com (Jason Friedman)
Newsgroups: comp.lang.python
Subject: Re: Two python issues
Date: Tue, 5 Nov 2024 14:08:45 -0700
Lines: 26
Message-ID: <mailman.83.1730840940.4695.python-list@python.org>
References: <700403c2-e052-4670-b2ec-eaf9b4babada@pandora.be>
<CANy1k1iML9=cKxhQfASBZDwqc_4N_E66MgXhddPf6zna3G-ckw@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de do8lSlEoM8sCtdM0f01towkk/2ycpZwm4cZcej+1wcMQ==
Cancel-Lock: sha1:lvsi1f7wb7LcqEY0xjBJWVUss/4= sha256:USBWoaacq1xIAXU5HSZtkjN7UjMp3LSwwMpKaaHbaNs=
Return-Path: <jsf80238@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=TTtddF4Y;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.107
X-Spam-Level: *
X-Spam-Evidence: '*H*': 0.79; '*S*': 0.00; 'cc:addr:python-list':
0.09; 'example:': 0.09; 'subject:python': 0.10; 'cc:no real
name:2**0': 0.14; 'option.': 0.16; 'says:': 0.16;
'subject:issues': 0.19; 'cc:addr:python.org': 0.20; 'cc:2**0':
0.25; 'bit': 0.27; '>>>': 0.28; 'think': 0.29; 'error': 0.29;
'message-id:@mail.gmail.com': 0.31; 'answers': 0.32; 'returning':
0.32; 'but': 0.32; "i'm": 0.33; 'header:In-Reply-To:1': 0.34;
'received:google.com': 0.34; 'from:addr:gmail.com': 0.34; 'item':
0.35; 'currently': 0.37; 'using': 0.37; 'url-ip:151.101.0.223/32':
0.38; 'url-ip:151.101.128.223/32': 0.38; 'url-
ip:151.101.192.223/32': 0.38; 'url-ip:151.101.64.223/32': 0.38;
'8bit%:14': 0.38; 'use': 0.39; 'should': 0.40; 'to:none': 0.61;
'method': 0.61; 'above': 0.62; 'skip:\xc2 10': 0.62; 'your': 0.64;
'bad': 0.67; 'refers': 0.69; 'little': 0.73; 'position': 0.81
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1730840936; x=1731445736; darn=python.org;
h=cc:subject:message-id:date:from:in-reply-to:references:mime-version
:from:to:cc:subject:date:message-id:reply-to;
bh=8k/AQXy/5r5mxkkITZjW2hJ4XqSFNp6CA7lmombq2/c=;
b=TTtddF4YFH9m6CZtswafiOUB9UusaAvD1jtcj043k57brsv0EbiPXA+abqO9GYZ8j0
IAS32C7/bnkpzXh6gp4ud412Kh2grFq297prwOFFv3HMXpXFghgMSdWh8lNzhOdtDKUj
W7rUcbBhUUbEd21vRgERxSGNmy9R01A9OcpWMl2uFSkTwC330El7KDxDGis+gubW1cEg
yFVohfMvie6SQGGupGXseNiaAEWtXHZNm8dtmwxLwC+d/gQQeuOg2caLW7RNmwkGWbga
eI8X1gGwgS8NcNpigy7EzeaTcOcqt6WmBLjgyTPBBm0bMyEsTWLI7A/AFxZbScgP1fR9
liKw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1730840936; x=1731445736;
h=cc: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=8k/AQXy/5r5mxkkITZjW2hJ4XqSFNp6CA7lmombq2/c=;
b=Qw2VQ1yLHGDUAI/1rbZdn0Yf0uZhLbGSO5+nwh+E89OKKsvbqPr4sR2S5vgO/051HE
6d8YA6sdewl8iYQ+vylAQqJUKMeNfPCo3EGhYufpyoeAKuhzgvW/l6YQXc+twILgT70E
I1wKtio8iHYexOBa+71SJZYVQLmglXjbXG7riehuoT2kC+0mOMc/CMHRhuM/9uVTpllI
QFpnh4HS1h4zHlSjPyxEu8b55Q0fD4du1z2L5nZj1pJJPMyWQNyNbpBD7g7NPlqx9L5w
YHK+R0XsZ3dHwDqQ65d7dFmq8epd4ckXux7Rl3R3GLhQxvuvCxoCGvlwCkm36HaDvAjt
jOeg==
X-Gm-Message-State: AOJu0YwDhhUr2ybxq2YSWpAzrbAhLztZhIha/RK5bpTqPqYTXNskUvXX
olc+r40P6y1vKhmXffq78Na5ITy7eqIW6DJG+l8NghYzrBRHKXNQlHPPUbO+AFPUdZ6tFfJKOO2
wkdEKbeZuej6nXbXnwdXrhhB7Qo+75OnQ
X-Google-Smtp-Source: AGHT+IEV5qOA2fOrbgfh/NKDK5d5whxeYkbPB76ddVf86nxNsy+YHg8Q4oC5JEgKMjjA56sQ7/NzU0WThZMjFWZXLhc=
X-Received: by 2002:a05:6820:501:b0:5eb:d1ac:21c4 with SMTP id
006d021491bc7-5ede662e486mr12209794eaf.8.1730840936124; Tue, 05 Nov 2024
13:08:56 -0800 (PST)
In-Reply-To: <700403c2-e052-4670-b2ec-eaf9b4babada@pandora.be>
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: <CANy1k1iML9=cKxhQfASBZDwqc_4N_E66MgXhddPf6zna3G-ckw@mail.gmail.com>
X-Mailman-Original-References: <700403c2-e052-4670-b2ec-eaf9b4babada@pandora.be>
View all headers

>
> (a) An error-prone "feature" is returning -1 if a substring is not found
> by "find", since -1 currently refers to the last item. An example:
>
> >>> s = 'qwertyuiop'
> >>> s[s.find('r')]
> 'r'
> >>> s[s.find('p')]
> 'p'
> >>> s[s.find('a')]
> 'p'
> >>>
>
> If "find" is unsuccessful, an error message is the only clean option.
> Moreover, using index -1 for the last item is a bad choice: it should be
> len(s) - 1 (no laziness!).
>

I'm not sure if this answers your objection but the note in the
documentation (https://docs.python.org/3/library/stdtypes.html#str.find)
says:

The find() method should be used only if you need to know the position of
sub.

I think the use case above is a little bit different.

1

rocksolid light 0.9.8
clearnet tor