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


Groups > comp.lang.python > #11167

Re: Bizarre behavior of the 'find' method of strings

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'mrab': 0.04; 'character,': 0.07; 'python': 0.08; 'between.': 0.09; 'identifies': 0.09; 'subject:method': 0.09; 'am,': 0.12; "subject:' ": 0.15; '(eg': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:Bizarre': 0.16; 'subject:behavior': 0.16; 'subject:find': 0.16; 'wrote:': 0.16; 'string,': 0.18; 'header:In-Reply-To:1': 0.22; 'end,': 0.23; 'slice': 0.23; 'aug': 0.24; 'index': 0.24; 'string': 0.26; 'thu,': 0.28; 'message-id:@mail.gmail.com': 0.29; 'characters,': 0.30; 'chris': 0.32; 'agree': 0.33; 'it.': 0.33; 'to:addr:python-list': 0.33; 'character': 0.34; 'rather': 0.35; 'uses': 0.35; 'beginning': 0.36; 'could': 0.38; 'think': 0.38; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.39; 'characters': 0.39; 'to:addr:python.org': 0.39; "it's": 0.40; 'alternative': 0.64; 'positions': 0.65; 'bible': 0.67; '11,': 0.68; 'wish': 0.69; 'inclusive': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=aK4by5RZU0710KCVvhOtAR1pnyDwABcEGUpsXVcG0EY=; b=F7aCDTFyBTGouAJjvbxuIwfzOIVuhgibdgtP/kpphjOhX4HwVfHGPSn+cw/v1dhohY Ljg+EzB3ghppJwuOgWVLx8rU8ER3XS4K4jhEdKvRkvskrC4Q+jhBOfaQAzarcCSYa1Nt YKscMP5SqfHPEk4+JnKVrGLcyILu/E41eqziU=
MIME-Version 1.0
In-Reply-To <4E4334F3.5000005@mrabarnett.plus.com>
References <2e5f052a-4922-433d-bbea-ec0c13e08a42@glegroupsg2000goo.googlegroups.com> <4E4334F3.5000005@mrabarnett.plus.com>
Date Thu, 11 Aug 2011 03:14:30 +0100
Subject Re: Bizarre behavior of the 'find' method of strings
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2138.1313028873.1164.python-list@python.org> (permalink)
Lines 15
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1313028873 news.xs4all.nl 23908 [2001:888:2000:d::a6]:46328
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:11167

Show key headers only | View raw


On Thu, Aug 11, 2011 at 2:48 AM, MRAB <python@mrabarnett.plus.com> wrote:
> Python uses half-open ranges, which means that the start position is
> inclusive and the end position is exclusive.
>

Or if you prefer: Python identifies positions between characters,
rather than characters. And I agree that it's better than the
alternative - in fact, I wish other systems could work the same way
(eg Bible references). If you think about position 0 being the very
beginning of the string, and position len(s) being the very end, then
you slice the string from position to position and take the characters
between. When you index the string for a particular character, you aim
at a position and take the character after it.

Chris Angelico

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


Thread

Bizarre behavior of the 'find' method of strings Jim <jianbao.tao@gmail.com> - 2011-08-10 18:24 -0700
  Re: Bizarre behavior of the 'find' method of strings MRAB <python@mrabarnett.plus.com> - 2011-08-11 02:48 +0100
  Re: Bizarre behavior of the 'find' method of strings Chris Angelico <rosuav@gmail.com> - 2011-08-11 03:14 +0100
  Re: Bizarre behavior of the 'find' method of strings Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-11 12:56 +1000
    Re: Bizarre behavior of the 'find' method of strings Chris Rebert <clp2@rebertia.com> - 2011-08-10 20:49 -0700
      Re: Bizarre behavior of the 'find' method of strings Jim <jianbao.tao@gmail.com> - 2011-08-10 21:29 -0700
      Re: Bizarre behavior of the 'find' method of strings Jim <jianbao.tao@gmail.com> - 2011-08-10 21:29 -0700

csiph-web