Path: csiph.com!usenet.pasdenom.info!goblin1!goblin.stu.neva.ru!news.astraweb.com!border5.a.newsrouter.astraweb.com!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed3.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.028 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'any.': 0.09; 'loop.': 0.09; 'semantics': 0.09; 'slices': 0.09; 'discussion.': 0.16; 'list;': 0.16; 'loops': 0.16; 'mainstream': 0.16; 'ranges.': 0.16; 'subject:)?': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'feb': 0.19; 'meant': 0.21; "haven't": 0.23; 'specifically': 0.24; 'header:In- Reply-To:1': 0.25; 'am,': 0.27; 'andrew': 0.27; 'message- id:@mail.gmail.com': 0.27; 'received:209.85.212': 0.28; 'actual': 0.28; 'run': 0.28; 'accidentally': 0.29; 'necessary,': 0.29; 'not.': 0.32; 'problem': 0.33; 'to:addr:python-list': 0.33; 'code:': 0.33; 'received:google.com': 0.34; 'received:209.85': 0.35; 'next': 0.35; 'list.': 0.35; 'but': 0.36; 'should': 0.36; 'subject: (': 0.36; 'does': 0.37; 'two': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'notice': 0.39; 'application': 0.40; 'easy': 0.60; 'between': 0.63; 'different': 0.63; 'ranges': 0.71; '2013': 0.84; 'to:name:python': 0.84; 'true!': 0.84; 'besides,': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=TK2SIUepNPicK1zrmmU3XCVA4J4BAvVUuETI20Qc25U=; b=MsRFFCy2B5Zv9C2KRZk3Jzww1M/z3Bxe3PLihtqCtRFTzBVbud/uyrWEYW09M6sed8 7i5+lxkp3sJ/cwFafOanh7RcBHd/3c86Lv7Jb2NOTtm7Lm5ePyfQLJ6UkpXU/D4SbfkW Psn5JtJB15siXjAzJ4szlQDkjwWoHl2sR4ZuMlywAHCzsnSUr7vBU04QG8TwEyFaGRQF /vgshZ04ExazA6JJfbbAEc2mCeDUnA65c0KpjWXwZAC5SgbvPvpx2CE7fGolzlTl8FrV ZsPK49IXae54Xhbq2NISU0Sxy00bL1iDVD1c/zr6ez6AYTEpkupCfwzIBGabjKNnpG6T Fx9A== X-Received: by 10.52.22.194 with SMTP id g2mr8956060vdf.91.1361811336206; Mon, 25 Feb 2013 08:55:36 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <512B15C0.8070106@r3dsolutions.com> References: <2e07acfb-4f48-4a27-9b06-3d8103325c0f@googlegroups.com> <512ABA02.2080709@r3dsolutions.com> <512B15C0.8070106@r3dsolutions.com> From: Ian Kelly Date: Mon, 25 Feb 2013 09:54:56 -0700 Subject: Re: Suggested feature: slice syntax within tuples (or even more generally)? 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: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1361811339 news.xs4all.nl 6982 [2001:888:2000:d::a6]:55214 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:39895 On Mon, Feb 25, 2013 at 12:41 AM, Andrew Robinson wrote: >> Intuitively, it should result in an infinite loop starting at 0. But >> ranges require a stop value for a very good reason -- it should not be >> this easy to accidentally create an infinite for loop. > > ... > and, besides, the same is true with other constructions of loops.... > > while a: # Damn easy, if a is accidentally true! Notice I specifically said an "infinite *for* loop". While loops are meant to be indeterminate in the number of iterations they will take going into the loop; for loops are not. >> The next problem you run into is that the semantics of negative >> numbers are completely different between slices and ranges. Consider >> this code: >> >> s = (-5:6) >> for i in s: >> print(i) >> for i in range(6)[s]: >> print(i) > > I don't find this difference to be necessary, nor objectionable. > > It is less inconsistent, in my view, to allow that > ([ 1,2,3,4,5 ])[-1:2] produce [5,1,2] than an empty list; > and ([ 1,2,3,4,5])[2:-1] does produce an empty list. > > I have been looking for actual programs that this would break for over two > months now, and I haven't been finding any. I am willing to run any > mainstream application you can find on test-patched python! Yes, I recollect now that we have already had this discussion.