Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed2.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.015 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'python.': 0.02; 'syntax': 0.03; 'python': 0.09; 'integers': 0.09; 'ruby,': 0.09; 'to:addr:comp.lang.python': 0.09; 'tutorials,': 0.09; 'cc:addr :python-list': 0.10; '(where': 0.15; 'represents': 0.15; '"s"': 0.16; 'doc:': 0.16; 'dots': 0.16; 'iteration': 0.16; 'plus,': 0.16; 'range.': 0.16; 'subject:)?': 0.16; 'sugar': 0.16; 'suggesting': 0.16; 'syntactic': 0.16; 'syntax.': 0.16; 'wrote:': 0.17; 'mechanism': 0.17; 'cc:2**0': 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'skip:[ 10': 0.26; 'correct': 0.28; 'arrays': 0.29; 'consistency': 0.29; 'quoting': 0.29; "i'm": 0.29; 'knows': 0.30; 'thursday,': 0.30; 'function': 0.30; 'anybody': 0.32; 'point.': 0.33; 'received:google.com': 0.34; 'consistent': 0.35; 'exist': 0.35; 'sequence': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'url:org': 0.36; 'should': 0.36; 'subject: (': 0.36; 'enough': 0.36; 'two': 0.37; 'uses': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'things': 0.38; 'instead': 0.39; 'application': 0.40; 'end': 0.40; 'think': 0.40; 'your': 0.60; 'range': 0.60; 'most': 0.61; 'between': 0.63; 'email addr:gmail.com': 0.63; 'love': 0.63; 'more': 0.63; 'request.': 0.64; 'importantly,': 0.65; 'today.': 0.69; 'applying': 0.69; 'biggest': 0.71; 'ranges': 0.71; 'manner': 0.74; '4th': 0.78; '2013': 0.84; 'excessive': 0.84; 'adopt': 0.91; 'approach.': 0.91; 'noise': 0.91 X-Received: by 10.49.87.9 with SMTP id t9mr30400qez.16.1360892819413; Thu, 14 Feb 2013 17:46:59 -0800 (PST) Newsgroups: comp.lang.python Date: Thu, 14 Feb 2013 17:46:59 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=70.196.65.73; posting-account=h3aEwQoAAACiuqX-oR3gvCVFm8lLHoWj References: <2e07acfb-4f48-4a27-9b06-3d8103325c0f@googlegroups.com> <511c9a66$0$11096$c3e8da3@news.astraweb.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 70.196.65.73 MIME-Version: 1.0 Subject: Re: Suggested feature: slice syntax within tuples (or even more generally)? From: Rick Johnson To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: , Message-ID: Lines: 75 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1360892826 news.xs4all.nl 6898 [2001:888:2000:d::a6]:46558 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:38901 On Thursday, February 14, 2013 4:01:39 PM UTC-6, steph...@gmail.com wrote: > On Thursday, February 14, 2013 1:58:06 PM UTC-5, Ian wrote: >=20 > [snip: quote noise!] >=20 Dude! Please trim this quote noise from your posts. I know Google's quoting= mechanism is buggy, but dammit man YOU'RE A PROGRAMER! There is no excuse = for not trimming excessive newlines. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D As to your slicing request. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Anybody who knows me KNOWS that i love consistency! So i'm all for applying= a slicing syntax consistently, however, i don't think your approach is the= correct approach.=20 To get you going in the correct direction: Ruby uses the "s..e" and "s...e= " (where "s" represents the start of the range and "e" represents the end o= f a range) as syntactic sugar for Range.new(s, e). Two dots create an /incl= usive/ range and three dots create an /exclusive/ range. Anyway, enough tut= orials, read the doc: http://www.ruby-doc.org/core-1.9.3/Range.html Now, i am not suggesting that python should adopt the /exact/ syntax of Rub= y, however, i /am/ suggesting that Ruby is more consistent with the range o= bject than Python. In Ruby: ...you can slice arrays with the range: =20 rb> a =3D [1,2,3,4,5] rb> a[0..-1] [1,2,3,4,5] rb> a[0...-1] [1,2,3,4] ...you can create a range of integers : rb> r =3D 1..10=20 rb> r.to_a() [1,2,3,4,5,6,7,8,9] ...you can create a range of chars: rb> r =3D "a".."d" rb> r.to_a() ["a", "b", "c", "d"] ...you can use range in a loop: rb> for x in 0...5;puts "#{x}th iteration";end 0th iteration 1th iteration 2th iteration 3th iteration 4th iteration ...but most importantly, you can do all these things in a consistent manner= using a consistent syntax! Python however has the stupid slice function and then sequence indexing, an= d no consistency between the two! Plus, the for loop uses the range functio= n to create "lazy iterators" instead of employing a consistent "range" synt= ax. Consistent syntax and consistent application are the biggest issues with Py= thon ranges as they exist today. That's the starting point.