Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #93771
| Path | csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.009 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'string.': 0.04; 'url:pipermail': 0.05; 'exist.': 0.09; 'subject:()': 0.09; 'thread': 0.10; 'python': 0.10; 'index': 0.13; 'argument': 0.15; 'bugs.': 0.16; 'subject:versus': 0.16; 'wrote:': 0.16; 'found,': 0.18; '2015': 0.20; 'am,': 0.23; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; 'message-id:@mail.gmail.com': 0.27; '13,': 0.29; 'question:': 0.29; 'str': 0.29; 'problem': 0.33; 'source': 0.33; 'url:python': 0.33; 'doubt': 0.33; 'that,': 0.34; 'list': 0.34; 'received:google.com': 0.35; 'but': 0.36; 'there': 0.36; 'url:org': 0.36; '2005': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'hi,': 0.38; 'why': 0.39; 'does': 0.39; "didn't": 0.39; 'url:mail': 0.40; 'to:addr:python.org': 0.40; 'jul': 0.72; 'python-dev': 0.84; 'to:name:python': 0.84; 'url :python-dev': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=LshUq0ze9wA3bHSlb0Duf1eebOI12gFrK1QYO7ODh5M=; b=tOGS1RGsbCiWZTIfs3+xNNl364KWfkYeaBOSjLjQBu4KQG5AAH/CGKkTSDe1aV7ahp 55cT10vy2NRbfF6H8j0SLZW/KoMTqg0p4XXjqstg53RwTvRjS/WJGTVPMqxu72ZRv48I z1GQCjTtHhh5q1ciIf8J+G+C7JF6efs/IJFJ5HcSMk4biVvlvqvvGMop5iUuzIXWIHym gSMfeMg8sekg1u1GJRfoKRVOQspzK1UK4AxFa27qgWCnopYgBDWAOm+BXGKGeumK9Fsd 1KsqZ9v+9f4UZ9e06fQYt1beiBgKXvogHSt8pbcNuNooSLr2r+vI3PiaIjTLWvWiB0Cy NQOw== |
| X-Received | by 10.129.94.70 with SMTP id s67mr5956252ywb.111.1436843577279; Mon, 13 Jul 2015 20:12:57 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <mo0qk1$ora$1@ger.gmane.org> |
| References | <mo0qk1$ora$1@ger.gmane.org> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Mon, 13 Jul 2015 21:12:18 -0600 |
| Subject | Re: str.index() and str.find() versus only list.index() |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| 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 | <http://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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.475.1436843580.3674.python-list@python.org> (permalink) |
| Lines | 15 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1436843580 news.xs4all.nl 2875 [2001:888:2000:d::a6]:39969 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:93771 |
Show key headers only | View raw
On Mon, Jul 13, 2015 at 10:56 AM, Roel Schroeven <roel@roelschroeven.net> wrote: > Hi, > > Quick question: why does str have both index() and find(), while list only > has index()? Is there a reason for that, or is it just an historical > accident? Historical accident, I think. If it were to be redone, I doubt that str.find would exist. The problem with it is that it returns -1 to indicate that the argument was not found, but -1 is a valid index into the string. This is a potential source of hard-to-find bugs. There was a long thread from 2005 on python-dev proposing to remove str.find in Python 3, but evidently it didn't make the cut: https://mail.python.org/pipermail/python-dev/2005-August/055704.html
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: str.index() and str.find() versus only list.index() Ian Kelly <ian.g.kelly@gmail.com> - 2015-07-13 21:12 -0600
Re: str.index() and str.find() versus only list.index() Steven D'Aprano <steve@pearwood.info> - 2015-07-14 13:23 +1000
Re: str.index() and str.find() versus only list.index() Ian Kelly <ian.g.kelly@gmail.com> - 2015-07-13 22:07 -0600
Re: str.index() and str.find() versus only list.index() Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-07-14 14:58 +1000
Re: str.index() and str.find() versus only list.index() Chris Angelico <rosuav@gmail.com> - 2015-07-14 15:13 +1000
csiph-web