Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsfeed.xs4all.nl!newsfeed5.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.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'example:': 0.03; 'desirable.': 0.07; 'empty,': 0.09; 'slices': 0.09; 'subject:()': 0.09; '9:20': 0.16; 'oct': 0.16; 'subject:array': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'examples': 0.18; 'obviously': 0.18; 'saying': 0.18; "python's": 0.23; 'this:': 0.23; 'header:In-Reply- To:1': 0.25; 'am,': 0.27; 'andrew': 0.27; 'list:': 0.27; 'message- id:@mail.gmail.com': 0.27; 'though.': 0.29; 'worked': 0.30; 'received:209.85.215.46': 0.30; 'code': 0.31; 'asking': 0.32; 'turns': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'received:209.85': 0.35; 'why': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'positive': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'skip:a 30': 0.60; 'skip:n 10': 0.63; 'stop,': 0.84; 'to:name:python': 0.84; 'do:': 0.91 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=t7s0ZAiGNzRfRykaZKcqduKnWlKpw0tMVbCzP71vTLY=; b=ibFgNFlwGLmidgPXGvWSYkt55tFOB+lG7MA7zpH9ioIampXvTV9aX0BJyud0R4jv0h epFWXbbZShLHRzfqMzh5NW9jfOiVqE6PlMd8dNJqBv9gb24PkpNBZeudscFPBH6KeBh9 K+hpWdiU8onnrDIEsQmOK0E3tBHgQsd6SnNgSRQzZFXuEdHWq5sgaxclAO/q9R6E93vK uslE3+wREBHR+H9ox9Lds1cuKdMT5uFd9tlltDHR8GR/1brOcEBw+Ul9N84eoPqwEiKp i00p1raSwRfpX6sMuMbJqs/E86lNXu5IqK9Z5li8MyPr9pCKNJWNEL9FOJHiNIqM+vMP a3TA== MIME-Version: 1.0 In-Reply-To: <508E9EBA.2070307@r3dsolutions.com> References: <6998a955-7b34-4f4f-b8d6-62d1028f7561@googlegroups.com> <4c024364-84df-403b-8b9e-4a4c8f06121c@googlegroups.com> <508e6649$0$29967$c3e8da3$5496439d@news.astraweb.com> <508E9EBA.2070307@r3dsolutions.com> From: Ian Kelly Date: Mon, 29 Oct 2012 17:01:29 -0600 Subject: Re: Negative array indicies and slice() To: Python Content-Type: text/plain; charset=ISO-8859-1 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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1351551720 news.xs4all.nl 6910 [2001:888:2000:d::a6]:37241 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32437 On Mon, Oct 29, 2012 at 9:20 AM, Andrew Robinson wrote: > FYI: I was asking for a reason why Python's present implementation is > desirable... > > I wonder, for example: > > Given an arbitrary list: > a=[1,2,3,4,5,6,7,8,9,10,11,12] > > Why would someone *want* to do: > a[-7,10] > Instead of saying > a[5:10] or a[-7:-2] ? A quick search of local code turns up examples like this: if name.startswith('{') and name.endswith('}'): name = name[1:-1] If slices worked like ranges, then the result of that would be empty, which is obviously not desirable. I don't know of a reason why one might need to use a negative start with a positive stop, though.