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


Groups > comp.lang.python > #48250

Re: Newbie: The philosophy behind list indexes

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <chris@rebertia.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.031
X-Spam-Evidence '*H*': 0.94; '*S*': 0.00; 'reason,': 0.07; '[0,': 0.09; 'explanation': 0.09; 'mind,': 0.09; 'cc:addr:python-list': 0.11; '[2,': 0.16; 'iterating': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'email addr:gmail.com&gt;': 0.22; 'cc:addr:python.org': 0.22; '&gt;&gt;&gt;': 0.24; 'stopping': 0.24; 'cheers,': 0.24; "haven't": 0.24; '(or': 0.24; 'cc:2**0': 0.24; '&gt;': 0.26; 'url:edu': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'errors': 0.30; 'subject:list': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'asked': 0.31; 'lists?': 0.31; 'quite': 0.32; 'sense': 0.34; 'but': 0.35; 'received:google.com': 0.35; '14,': 0.36; 'behind': 0.37; 'searching': 0.37; 'pm,': 0.38; 'rather': 0.38; 'sure': 0.39; 'subject:The': 0.64; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'hours': 0.66; 'answer.': 0.68; 'observed': 0.84; 'sender:addr:chris': 0.84; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=OTo0lcXHQ9nXMMcKBQYXZ/nNfPhfARkeZLb65FElGbc=; b=aPlEdoQNjGLb5Mx81mhl97Kr7+MuqglB2Z5CLS8tlHvXUhezkfq2zb3smsunLVGsvr REEh+jJwoRylpfMeOkGtm8KLq0Du3LVcl3dGGSG8wnfR/gEdQrcE12O04BXV34i0mOei Befo7FMuo3ghjUEqLDjyyU7HLSd861uyI9hWs=
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :x-gm-message-state; bh=OTo0lcXHQ9nXMMcKBQYXZ/nNfPhfARkeZLb65FElGbc=; b=HOcDyx4VbEMkU/1EpqCiGGon6egHrB9rUUK/vh3wlx7PH35aqbOcFlcX8V5Cpl0BAX DNAkS6Aol825b5UvaGVtDJ4BkUpg9AWfEZeS+O2EUTxiCOfzIKT8oZk+PIoNcIolOdAZ ntGUTQ9tBTlEDqOvEcjaQVDxn7HPw/b25cNDm5YaKe3K0cdvHMGNZZP8WKtxM2RvEMdm Cr7AjVgPDlaih9bO4Bnn0JH3S3Wo1h1ixABcdPy9Of7ogv6rjOiQMkaxlUXsJ6/78YZC IGdLyNPWy+jV/K8laAYpthWtQwxPqyL6Qs89kOlYdUIlUfkef11mp1hIJtWZ6eBPRulC 3FUA==
MIME-Version 1.0
X-Received by 10.50.29.79 with SMTP id i15mr380438igh.106.1371274507113; Fri, 14 Jun 2013 22:35:07 -0700 (PDT)
Sender chris@rebertia.com
In-Reply-To <f0ef08bc-464d-4d36-b285-ebc3c7ffb337@googlegroups.com>
References <f0ef08bc-464d-4d36-b285-ebc3c7ffb337@googlegroups.com>
Date Fri, 14 Jun 2013 22:35:06 -0700
X-Google-Sender-Auth 6hcw78UmYtGNTZEJhyptAoLQvxE
Subject Re: Newbie: The philosophy behind list indexes
From Chris Rebert <clp2@rebertia.com>
To ian.l.cameron@gmail.com
Content-Type multipart/alternative; boundary=047d7bd75514e2ec1c04df2ab900
X-Gm-Message-State ALoCoQnZ/O8prV7PtlIlbmbiP1CvGXmlDeapo4T/R6POMrvY3+GO2T4v+YBGIFCcT/VNka0PAUxH
Cc Python <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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.3356.1371274509.3114.python-list@python.org> (permalink)
Lines 61
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1371274509 news.xs4all.nl 15930 [2001:888:2000:d::a6]:55004
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:48250

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On Jun 14, 2013 10:26 PM, <ian.l.cameron@gmail.com> wrote:
> I bet this is asked quite frequently, however after quite a few hours
searching I haven't found an answer.
>
> What is the thinking behind stopping 'one short' when slicing or
iterating through lists?
>
> By example;
>
> >>> a=[0,1,2,3,4,5,6]
> >>> a
> [0, 1, 2, 3, 4, 5, 6]
> >>> a[2:5]
> [2, 3, 4]
>
> To my mind, it makes more sense to go to 5. I'm sure there's a good
reason, but I'm worried it will result in a lot of 'one-off' errors for me,
so I need to get my head around the philosophy of this behaviour, and where
else it is observed (or not observed.)

I find Dijkstra's explanation rather convincing:
http://www.cs.utexas.edu/~EWD/transcriptions/EWD08xx/EWD831.html

Cheers,
Chris

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


Thread

Newbie: The philosophy behind list indexes ian.l.cameron@gmail.com - 2013-06-14 22:21 -0700
  Re: Newbie: The philosophy behind list indexes Chris Rebert <clp2@rebertia.com> - 2013-06-14 22:35 -0700
  Re: Newbie: The philosophy behind list indexes Chris Angelico <rosuav@gmail.com> - 2013-06-15 15:49 +1000
  Re: Newbie: The philosophy behind list indexes Peter Otten <__peter__@web.de> - 2013-06-15 08:42 +0200
  Re: Newbie: The philosophy behind list indexes John Ladasky <john_ladasky@sbcglobal.net> - 2013-06-15 00:19 -0700
  Re: Newbie: The philosophy behind list indexes Olive <not0read0765@yopmail.com> - 2013-06-15 09:44 +0200
  Re: Newbie: The philosophy behind list indexes ian.l.cameron@gmail.com - 2013-06-19 13:46 -0700

csiph-web