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!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; 'python.': 0.02; 'example:': 0.03; 'algorithm': 0.03; 'badly': 0.07; 'received:64.202.165': 0.07; 'agrees': 0.09; 'naturally': 0.09; 'subject:()': 0.09; 'index': 0.13; 'index.': 0.16; 'ring,': 0.16; 'roy': 0.16; 'subject:array': 0.16; 'wrote:': 0.17; 'circular': 0.17; 'thanks,': 0.18; 'saying': 0.18; 'trying': 0.21; 'do.': 0.21; 'orientation': 0.22; 'example': 0.23; "python's": 0.23; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'list:': 0.27; 'asking': 0.32; 'right?': 0.33; 'to:addr :python-list': 0.33; 'another': 0.33; 'list': 0.35; 'community': 0.35; 'scientific': 0.36; 'possible': 0.37; 'why': 0.37; 'subject:: ': 0.38; 'positive': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'list,': 0.39; 'where': 0.40; 'think': 0.40; 'your': 0.60; 'skip:a 30': 0.60; 'lower': 0.61; 'show': 0.63; 'behavior': 0.64; 'grab': 0.64; 'decided': 0.65; 'header :Reply-To:1': 0.68; 'smith': 0.71; 'reply-to:no real name:2**0': 0.72; 'do:': 0.91 Date: Mon, 29 Oct 2012 08:20:26 -0700 From: Andrew Robinson User-Agent: Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20111126 Thunderbird/8.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Negative array indicies and slice() References: <6998a955-7b34-4f4f-b8d6-62d1028f7561@googlegroups.com> <4c024364-84df-403b-8b9e-4a4c8f06121c@googlegroups.com> <508e6649$0$29967$c3e8da3$5496439d@news.astraweb.com> In-Reply-To: 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.15 Precedence: list Reply-To: andrew3@r3dsolutions.com 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: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1351549341 news.xs4all.nl 6957 [2001:888:2000:d::a6]:37625 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32428 On 10/29/2012 06:52 AM, Roy Smith wrote: > Show me an example where someone would write a slice with a negative and > a positive index (both in the same slice); > and have that slice grab a contiguous slice in the *middle* of the list > with orientation of lower index to greater index. > It's possible in bioinformatics. ... > eq[100:-100]. I decided to go to bed... I was starting to write very badly worded responses. :) Thanks, Roy, what you have just shown is another example that agrees with what I am trying to do. 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] ? eg: What algorithm would naturally *desire* the default behavior of slicing when using *mixed* negative and positive indexes? In the case of a bacterial circular DNA/RNA ring, asking for codons[ -10: 10 ] would logically desire codon[-10:] + codon[:10] not an empty list, right? I think your example is a very reasonable thing the scientific community would want to do with Python. :)