Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #11166
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python@mrabarnett.plus.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; 'python': 0.08; '>>>>': 0.09; 'folks,': 0.09; 'from:addr:python': 0.09; 'subject:method': 0.09; "subject:' ": 0.15; 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:84.92': 0.16; 'received:84.92.122': 0.16; 'received:84.92.122.60': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'reply-to:addr:python-list': 0.16; 'subject:Bizarre': 0.16; 'subject:behavior': 0.16; 'subject:find': 0.16; 'wrote:': 0.16; 'language': 0.17; 'programming': 0.20; 'this?': 0.21; 'header:In-Reply-To:1': 0.22; 'extending': 0.23; 'string': 0.26; 'received:84': 0.28; 'fewer': 0.30; "can't": 0.33; 'to:addr:python-list': 0.33; 'header:User-Agent:1': 0.34; 'reply- to:addr:python.org': 0.34; 'uses': 0.35; 'thank': 0.35; '(with': 0.35; 'starting': 0.36; 'jim': 0.37; 'using': 0.37; 'but': 0.37; 'something': 0.37; 'think': 0.38; 'subject:: ': 0.39; 'help': 0.39; 'why': 0.39; 'to:addr:python.org': 0.39; 'results': 0.61; 'here': 0.65; 'greetings,': 0.66; 'header:Reply-To:1': 0.71; 'reply-to:no real name:2**0': 0.71; 'inclusive': 0.84; 'ranges': 0.91 |
| X-IronPort-Anti-Spam-Filtered | true |
| X-IronPort-Anti-Spam-Result | AiQGAPYzQ05UXebj/2dsb2JhbABBmDqPBneBQAEBBThAEQsIEAkUAg8JAwIBAgFFEwgBAYdsvQuGRgSYFItk |
| Date | Thu, 11 Aug 2011 02:48:35 +0100 |
| From | MRAB <python@mrabarnett.plus.com> |
| User-Agent | Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20110624 Thunderbird/5.0 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: Bizarre behavior of the 'find' method of strings |
| References | <2e5f052a-4922-433d-bbea-ec0c13e08a42@glegroupsg2000goo.googlegroups.com> |
| In-Reply-To | <2e5f052a-4922-433d-bbea-ec0c13e08a42@glegroupsg2000goo.googlegroups.com> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| Reply-To | python-list@python.org |
| 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.2137.1313027314.1164.python-list@python.org> (permalink) |
| Lines | 23 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1313027314 news.xs4all.nl 23952 [2001:888:2000:d::a6]:51963 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:11166 |
Show key headers only | View raw
On 11/08/2011 02:24, Jim wrote:
> Greetings, folks,
>
> I am using python 2.7.2. Here is something I got:
>>>> a = 'popular'
>>>> i = a.find('o')
>>>> j = a.find('a')
>>>> a[i:j]
> 'opul'
>
> Well, I expected a[i:j] to be 'opula', and can't think of any reason
> why this is not happening. So, can anybody help me out about this?
> Thank you very much.
>
Python uses half-open ranges, which means that the start position is
inclusive and the end position is exclusive.
This means that a[i:j] returns the string starting at position i and
extending upto, but excluding, position j.
The reason that Python uses half-open ranges is that experience (with
the language Mesa) has shown that it results in fewer programming
errors that the alternatives.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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