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: 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>': 0.22; 'cc:addr:python.org': 0.22; '>>>': 0.24; 'stopping': 0.24; 'cheers,': 0.24; "haven't": 0.24; '(or': 0.24; 'cc:2**0': 0.24; '>': 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: References: 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 To: ian.l.cameron@gmail.com Content-Type: multipart/alternative; boundary=047d7bd75514e2ec1c04df2ab900 X-Gm-Message-State: ALoCoQnZ/O8prV7PtlIlbmbiP1CvGXmlDeapo4T/R6POMrvY3+GO2T4v+YBGIFCcT/VNka0PAUxH Cc: Python X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 --047d7bd75514e2ec1c04df2ab900 Content-Type: text/plain; charset=UTF-8 On Jun 14, 2013 10:26 PM, 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 --047d7bd75514e2ec1c04df2ab900 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

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=3D[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&#= 39; errors for me, so I need to get my head around the philosophy of this b= ehaviour, 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

--047d7bd75514e2ec1c04df2ab900--