Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #196959

Two python issues

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Raymond Boute <raymond.boute@pandora.be>
Newsgroups comp.lang.python
Subject Two python issues
Date Tue, 5 Nov 2024 15:48:07 +0100
Lines 36
Message-ID <mailman.80.1730839406.4695.python-list@python.org> (permalink)
References <700403c2-e052-4670-b2ec-eaf9b4babada@pandora.be>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 8bit
X-Trace news.uni-berlin.de QW5XEfkMaOHXERL6fahY1Q3waWYuoXjVCXSkWbz5Ef6Q==
Cancel-Lock sha1:SpcBqJBlFlkuFpkfdC+Drf+9nsc= sha256:Rp0ZYm4T3sQpyON3Sf5SppUT3D7qq6h0AW7zUxm56tA=
Return-Path <raymond.boute@pandora.be>
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=pandora.be header.i=@pandora.be header.b=NLZi8dFx; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status UNSURE 0.220
X-Spam-Level **
X-Spam-Evidence '*H*': 0.59; '*S*': 0.03; 'comments': 0.03; 'example:': 0.09; 'subject:python': 0.10; '(b)': 0.16; 'option.': 0.16; 'received:be': 0.16; 'welcome.': 0.16; 'python': 0.16; 'subject:issues': 0.19; 'to:addr:python-list': 0.20; 'idea': 0.24; 'anything': 0.25; '>>>': 0.28; 'error': 0.29; 'header:User- Agent:1': 0.30; 'seem': 0.31; 'elements': 0.32; 'language.': 0.32; 'negative': 0.32; 'returning': 0.32; 'but': 0.32; 'same': 0.34; 'item': 0.35; 'lists': 0.37; 'currently': 0.37; 'using': 0.37; 'list': 0.39; 'changes': 0.39; 'otherwise': 0.39; 'should': 0.40; 'best': 0.61; 'bad': 0.67; 'items': 0.68; 'refers': 0.69; 'essential': 0.70; 'longer': 0.71; 'covered': 0.75; 'solutions.': 0.75; '(e.g.,': 0.76; 'poor': 0.76; 'cleaner': 0.84; 'indices': 0.84; 'preceding': 0.84; 'strings': 0.84; 'affect': 0.91; 'suffer': 0.91
User-Agent Mozilla Thunderbird
Content-Language en-US
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=pandora.be; s=p24; t=1730818089; bh=5x8kcXClyn0w692908zIMOGWlV5ioo7CZFLarF1Ow5o=; h=Message-ID:Date:MIME-Version:To:From:Subject:Content-Type: Content-Transfer-Encoding:From; b=NLZi8dFx1hxI1K7N8MVv7VobsAqywU1mBsDBt+4ks04RXSbgpqNtWetdmg2dcP7/Z fWYjna3PqkEwgg1jgPR6RryzzqOf6KijVEq6zh+Eel8/cgieKHmyzwuBU8Pxha4ZVk hqNY+23d4vz0iurLI1DFRfxAeMk1QdIHBuLL5lTVLGmWLoOPFbsAd3YswXQgYVJY57 EERjQMIsqLBee+sU53tNeskDl7pqxFqbKq8A1w3udvw4NkUPpSuRBOWuSt/B3Bz4Sa NBg5qvTdTAu1pXBcO1/bHCM3ww5oC17trrFfWhLoLyjrBw4wqovKZKkNwl7LghaBys EAgJTk7Rs95ZQ==
X-Mailman-Approved-At Tue, 05 Nov 2024 15:43:25 -0500
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 <700403c2-e052-4670-b2ec-eaf9b4babada@pandora.be>
Xref csiph.com comp.lang.python:196959

Show key headers only | View raw


L.S.,

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. 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!).
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).

(b) When using assignment for slices, only lists with the same length as 
the slice should be acceptable, otherwise an error should be given.  
Anything that re-indexes items not covered by the slice is against the 
essential idea of assignment. For changes that imply re-indexing (e.g., 
inserting a list longer than the slice), Python offers cleaner solutions.

Comments are welcome.

With best regards,

Raymond

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Two python issues Raymond Boute <raymond.boute@pandora.be> - 2024-11-05 15:48 +0100
  Re: Two python issues Piergiorgio Sartor <piergiorgio.sartor.this.should.not.be.used@nexgo.REMOVETHIS.de> - 2024-11-05 22:27 +0100
    Re: Two python issues (Posting On Python-List Prohibited) Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-11-05 21:56 +0000

csiph-web