Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.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: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'bits': 0.07; 'keys,': 0.07; 'python': 0.09; 'oh,': 0.09; 'subject:()': 0.09; 'java,': 0.15; "'c',": 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'haskell,': 0.16; 'idle.': 0.16; 'iterator': 0.16; 'lisp,': 0.16; 'oct': 0.16; 'operation,': 0.16; 'slicing,': 0.16; 'subject:array': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'written,': 0.17; 'written': 0.20; 'sort': 0.21; 'produces': 0.22; 'least': 0.25; 'header:In-Reply-To:1': 0.25; 'wonder': 0.27; 'have,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'all.': 0.28; "d'aprano": 0.29; 'steven': 0.29; 'probably': 0.29; 'like:': 0.33; 'point,': 0.33; 'values.': 0.33; 'to:addr:python-list': 0.33; 'languages': 0.33; 'version': 0.34; 'received:google.com': 0.34; 'so,': 0.35; 'pm,': 0.35; 'similar': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'but': 0.36; 'useful': 0.36; 'should': 0.36; 'quite': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'most': 0.61; 'more': 0.63; 'firing': 0.84; 'thing,': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=FePFqTOjc2/0NgMG63XOF4JRBq81jlFLtixEl5xZPNA=; b=iN2pSa9gsxFSSIh13uTa0vnvsFyc2Us1S0fmsZv75HhdM6C9JLfKTvc+6gOatN0I4O XBepPa3k8NOzqvoY6Disg4SZmLMslnHl8hqO2fDi/TiEeV5oVs3/c7yAFWkYch0KioC+ tVZpra0chxRNtT1AXu9vWb3QjFHTnIcUxeb3EXLtV32gafryyPGneuXK1J9ajQA2QA74 Jx3+4sq2nYE0fyx4NoY/UczuEsBEgIbrYKqQxlmwRqrGLWlIeaCwbbEUGDa3Xp+xd4Gv Y3noKlewmWvoZ4niQPA6FIxdX2EjzadAStf6Z/OVr5w0TSLk4eQypz0BxcQFyU31CEMO bpUQ== MIME-Version: 1.0 In-Reply-To: <508e6649$0$29967$c3e8da3$5496439d@news.astraweb.com> References: <6998a955-7b34-4f4f-b8d6-62d1028f7561@googlegroups.com> <4c024364-84df-403b-8b9e-4a4c8f06121c@googlegroups.com> <508e6649$0$29967$c3e8da3$5496439d@news.astraweb.com> Date: Mon, 29 Oct 2012 22:32:05 +1100 Subject: Re: Negative array indicies and slice() From: Chris Angelico To: python-list@python.org 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: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1351510328 news.xs4all.nl 6932 [2001:888:2000:d::a6]:55780 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32360 On Mon, Oct 29, 2012 at 10:19 PM, Steven D'Aprano wrote: >> In 'C', where Python is written, > > That's a popular misapprehension. Python is written in Java, or Lisp, or > Haskell, or CLR (dot Net), or RPython, or Ocaml, or Parrot. Each of those > languages have, or had, at least one Python implementation. Oh, there's > also a version written in C, or so I have heard. And that's not including the human-brain implementation, perhaps the most important of all. Although the current port of Python to my brain isn't quite a complete implementation, lacking a few bits that I should probably get to at some point, but even so, it's as useful to me as firing up IDLE. I wonder if what the OP is looking for is not slicing, but something more akin to map. Start with a large object and an iterator that produces keys, and create an iterator/list of their corresponding values. Something like: a=[1,2,3,4,5,6,7,8,9,10] b=[a[i] for i in xrange(-4,3)] It's not strictly a slice operation, but it's a similar sort of thing, and it can do the wraparound quite happily. ChrisA