Deutsch   English   Français   Italiano  
<mailman.82.1730840778.4695.python-list@python.org>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!news.nobody.at!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: Cameron Simpson <cs@cskk.id.au>
Newsgroups: comp.lang.python
Subject: Re: Two python issues
Date: Wed, 6 Nov 2024 08:06:12 +1100
Lines: 40
Message-ID: <mailman.82.1730840778.4695.python-list@python.org>
References: <700403c2-e052-4670-b2ec-eaf9b4babada@pandora.be>
 <ZyqIxGMojbeDzq63@cskk.homeip.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
X-Trace: news.uni-berlin.de hEAAa72BbuNwngB94n7zhw7MMU8bXN88RfW1FdHczjQQ==
Cancel-Lock: sha1:O923pUtVLDJXbiDXh7acqyB3LYA= sha256:LZJOaFe51Vwb7TsqNGPNfwpicsFiDC2RjESKUSbQEDw=
Return-Path: <cameron@cskk.id.au>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
 dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.004
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'is.': 0.05; 'string':
 0.07; 'tests': 0.07; 'cc:addr:python-list': 0.09; 'something,':
 0.09; 'subject:python': 0.10; 'cheers,': 0.11; 'cc:no real
 name:2**0': 0.14; 'cameron': 0.16; 'circumstance': 0.16;
 'feature.': 0.16; 'found.': 0.16; 'from:addr:cs': 0.16;
 'from:addr:cskk.id.au': 0.16; 'from:name:cameron simpson': 0.16;
 'length.': 0.16; 'loops': 0.16; 'message-id:@cskk.homeip.net':
 0.16; 'option.': 0.16; 'received:13.237': 0.16;
 'received:13.237.201': 0.16; 'received:13.237.201.189': 0.16;
 'received:cskk.id.au': 0.16; 'received:id.au': 0.16;
 'received:mail.cskk.id.au': 0.16; 'simpson': 0.16; 'wrote:': 0.16;
 'api': 0.17; 'instead': 0.17; 'calls': 0.19; 'subject:issues':
 0.19; 'cc:addr:python.org': 0.20; "i've": 0.22; 'cc:2**0': 0.25;
 'old': 0.27; 'error': 0.29; 'header:User-Agent:1': 0.30; 'seem':
 0.31; 'elements': 0.32; 'language.': 0.32; 'negative': 0.32;
 'obtain': 0.32; 'returning': 0.32; 'but': 0.32; 'there': 0.33;
 'header:In-Reply-To:1': 0.34; 'same': 0.34; 'item': 0.35;
 'received:au': 0.35; 'lists': 0.37; 'currently': 0.37; 'using':
 0.37; 'way': 0.38; 'error,': 0.38; 'quite': 0.39; 'otherwise':
 0.39; 'true.': 0.40; 'want': 0.40; 'should': 0.40; 'view': 0.60;
 'less': 0.64; 'received:13': 0.64; 'look': 0.65;
 'received:userid': 0.66; 'bad': 0.67; 'change.': 0.69; 'refers':
 0.69; 'sequence': 0.69; 'depending': 0.70; 'late': 0.73; 'poor':
 0.76; 'choices': 0.84; 'indices': 0.84; 'preceding': 0.84;
 'affect': 0.91; 'suffer': 0.91
Mail-Followup-To: Raymond Boute <raymond.boute@pandora.be>,
 python-list@python.org
Content-Disposition: inline
In-Reply-To: <700403c2-e052-4670-b2ec-eaf9b4babada@pandora.be>
User-Agent: Mutt/2.2.13 (2024-03-09)
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: <ZyqIxGMojbeDzq63@cskk.homeip.net>
X-Mailman-Original-References: <700403c2-e052-4670-b2ec-eaf9b4babada@pandora.be>
Bytes: 5266

On 05Nov2024 15:48, Raymond Boute <raymond.boute@pandora.be> wrote:
>Python seem to suffer from a few poor design decisions regarding 
>strings and lists that affect the elegance of the language.
>
>(a) An error-prone "feature" is returning -1 if a substring is not 
>found by "find", since -1 currently refers to the last item.

`find` is a pretty old API interface. It is what it is. It may obtain 
some of its design choices from C style calls where returning -1 for 
failure was a common idiom.

>If "find" is unsuccessful, an error message is the only clean option.

This is not true. Often we want to look for something, and act one way 
or another depending on whether it is found. I've got plenty of loops 
and other tests which more or less go "run until this is not found". It 
is not an error, it is just a circumstance to accomodate.

>Moreover, using index -1 for the last item is a bad choice: it should 
>be len(s) - 1 (no laziness!).
>Negative indices should be reserved for elements preceding the element 
>with index 0 (currently not implemented, but a must for orthogonal 
>design supporting general sequences).

It is _far_ too late to propose such a change.

Plenty of us are quite hapoy with negative indices. We just view them as 
counting backwarss from the end of the string or sequence instead of 
forwards from the beginning.

>(b) When using assignment for slices, only lists with the same length 
>as the slice should be acceptable, otherwise an error should be 
>given.

There are many many circumstances where we replace a subsequence with a 
different subsequence of different length. Outlawing such a thing would 
remove and extremely useful feature.

Cheers,
Cameron Simpson <cs@cskk.id.au>