Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed1.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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python.': 0.02; 'output': 0.05; 'list?': 0.07; 'subject:PEP': 0.07; 'string': 0.09; 'alter': 0.09; 'slices': 0.09; 'cc:addr:python-list': 0.11; 'question.': 0.14; '12:50': 0.16; 'easily,': 0.16; 'example?': 0.16; 'given,': 0.16; 'splitting': 0.16; 'stuff.': 0.16; 'through.': 0.16; 'thursday,': 0.16; 'wrote:': 0.18; 'looked': 0.18; 'bit': 0.19; 'trying': 0.19; 'thu,': 0.19; 'written': 0.21; 'seems': 0.21; 'example': 0.22; 'aug': 0.22; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'certainly': 0.24; 'looks': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '>': 0.26; 'right.': 0.26; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'lists': 0.32; 'option': 0.32; 'quite': 0.32; 'url:python': 0.33; 'cases': 0.33; 'founded': 0.33; 'style': 0.33; 'maybe': 0.34; 'subject:from': 0.34; 'could': 0.34; 'problem': 0.35; 'basic': 0.35; 'agree': 0.35; 'something': 0.35; 'subject:lists': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'wishes,': 0.36; 'url:listinfo': 0.36; 'doing': 0.36; 'useful': 0.36; 'possible': 0.36; 'url:org': 0.36; 'should': 0.36; 'list': 0.37; 'list.': 0.37; 'skip:& 10': 0.38; 'pm,': 0.38; 'does': 0.39; 'enough': 0.39; 'skip:p 20': 0.39; 'url:mail': 0.40; 'august': 0.61; 'simple': 0.61; "you've": 0.63; 'kind': 0.63; 'more': 0.64; 'occur': 0.65; 'to:addr:gmail.com': 0.65; 'jobs': 0.68; 'natural': 0.68; 'case?': 0.84; 'improvement': 0.84; 'quicker': 0.84; 'afford': 0.91; '2013': 0.98 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 :cc:content-type; bh=es4uVmkra3LwgYPZu07Ec6WapvIGxyg3JiQczSQV6dM=; b=UD93gALm2Ml22VllRKaTG5IUsyvHaNX1KUAmX6I7M1qLWqvkB5uXTycqy2mYnNAcMP 181DVYh0LIQPnEL4f9ssgPR5n161tiYLEFsl1esATgRB48aYX5eABo307xj8IywENwhF EeYwB55R2Cf2rKoAXfS1IGceMrfdlOB6aP6z/9Na9u3f2GIoUPYZhLlAlIWSttmAdksn NeWyJZZEi5RZ6uHDNSSLikg5l9iGJ5DF0bPuOCnaB3L4yPKJT7XsXLMpA4VuM5bVhVL8 BJHo9oJxWAN44zV9Vu90DP0GAPg4MtLfAdQMBMKRGjW7V0qeaIJVvd2RpVxMRx9vNt+s fiDg== MIME-Version: 1.0 X-Received: by 10.49.1.50 with SMTP id 18mr6232906qej.13.1375970599265; Thu, 08 Aug 2013 07:03:19 -0700 (PDT) In-Reply-To: <7c8c0342-f533-4e2e-9df4-71b2ccaf1929@googlegroups.com> References: <531d89a8-61e1-4117-b4cc-f02b3be30bb9@googlegroups.com> <9bd6192b-2c71-4662-808a-fd7e74dedeb8@googlegroups.com> <62769807-dff7-40a0-a060-d1e0b7c0685f@googlegroups.com> <7c8c0342-f533-4e2e-9df4-71b2ccaf1929@googlegroups.com> Date: Thu, 8 Aug 2013 15:03:19 +0100 Subject: Re: Suggestion: PEP for popping slices from lists From: Nicholas Cole To: Neatu Ovidiu Content-Type: multipart/alternative; boundary=047d7b677442ca6cde04e3701e02 Cc: python-list@python.org 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: 436 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1375970608 news.xs4all.nl 15876 [2001:888:2000:d::a6]:54069 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:52197 --047d7b677442ca6cde04e3701e02 Content-Type: text/plain; charset=ISO-8859-1 On Thu, Aug 8, 2013 at 2:32 PM, Neatu Ovidiu wrote: > On Thursday, August 8, 2013 4:08:13 PM UTC+3, Nicholas wrote: > > On Thu, Aug 8, 2013 at 12:50 PM, Neatu Ovidiu wrote: > > > > > > > > > > On Thursday, August 8, 2013 2:44:05 PM UTC+3, Neatu Ovidiu wrote: > > > > > On Thursday, August 8, 2013 2:12:53 PM UTC+3, Nicholas wrote: > > > > > > > > > > > On Thu, Aug 8, 2013 at 11:38 AM, Neatu Ovidiu > wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > But what's your use case? > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Does it occur often enough that you cannot afford a two-liner like > > > > > > > > > > > > > > > > > > > > > > I think uses cases are plenty. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > The possible cases I can think of would be better served with list > comprehensions (what you seem to want is to create lists based on other > lists) - but maybe I'm missing something. Could we have one example? > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > N. > > > > > > > > > > > > > > > > > > > > This can be useful for doing all kinds of basic stuff. For example if > you wanted to take 4 items of a list at at a time, do something with them > and then update the list. > > > > > > > > > > > > > > > > > > > > jobs = ['job1', 'job2', 'job3', 'job4', 'job5', 'job6', 'job7', > 'job8', 'job9', 'job10'] > > > > > > > > > > while jobs: > > > > > > > > > > print(jobs.pop_slice(0,4)) > > > > > > > > > > > > > > > > > > > > should output > > > > > > > > > > > > > > > > > > > > 'job1', 'job2', 'job3', 'job4' > > > > > > > > > > 'job5', 'job6', 'job7', 'job8' > > > > > > > > > > 'job9', 'job10' > > > > > > > > The idea "popped" in my mind while thinking about this question. > > > > > http://stackoverflow.com/questions/18121416/right-split-a-string-into-groups-of-3/18122084 > > > > I founded the list comprehensions solutions kind of cumbersome and > thought that there should be a simple way to do this kind of stuff. > > > > -- > > > > http://mail.python.org/mailman/listinfo/python-list > > > > > > > > > > > > Still seems a bit like a solution looking for a problem to me. > > > > > > > > Why would you want to take four items at a time for a job from an > arbitrary part of a list? I agree splitting a string into groups of three > looks a bit cumbersome in the example you've given, but a generator could > be written quite easily, and would almost certainly be quicker than trying > to alter the list in place. > > > > > > > > Best wishes, > > > > > > N. > > You are perfectly right. But I looked at it more like an improvement in > the style of writing solutions and also a natural option because slices are > highly present all over in python. > I wasn't knocking it. I was just trying to think it through. --047d7b677442ca6cde04e3701e02 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable



On Thu, Aug 8, 2013 at 2:32 PM, Neatu Ovidiu <= neatuovi@gmail.com<= /a>> wrote:
On Thursday, August 8, 2013 4:08:13 PM UTC+3= , Nicholas wrote:
> On Thu, Aug 8, 2013 at 12:50 PM, Neatu Ovidiu &= lt;neat...@gmail.com> wrote: >
>
>
>
> On Thursday, August 8, 2013 2:44:05 PM UTC+3, Neatu Ovidiu wrote:
>
> > On Thursday, August 8, 2013 2:12:53 PM UTC+3, Nicholas wrote:
>
> >
>
> > > On Thu, Aug 8, 2013 at 11:38 AM, Neatu Ovidiu <neat...@gmail.com> wrote:
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > > But what's your use case?
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > Does it occur often enough that you cannot afford a two= -liner like
>
> >
>
> > >
>
> >
>
> > > I think uses cases are plenty.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > The possible cases I can think of would be better served wit= h list comprehensions (what you seem to want is to create lists based on ot= her lists) - but maybe I'm missing something. =A0Could we have one exam= ple?
>
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > N.
>
> >
>
> >
>
> >
>
> > This can be useful for doing all kinds of basic stuff. For exampl= e if you wanted to take 4 items of a list at at a time, do something with t= hem and then update the list.
>
> >
>
> >
>
> >
>
> > jobs =3D ['job1', 'job2', 'job3', 'jo= b4', 'job5', 'job6', 'job7', 'job8', &#= 39;job9', 'job10']
>
> >
>
> > while jobs:
>
> >
>
> > =A0 =A0 print(jobs.pop_slice(0,4))
>
> >
>
> >
>
> >
>
> > should output
>
> >
>
> >
>
> >
>
> > 'job1', 'job2', 'job3', 'job4' >
> >
>
> > 'job5', 'job6', 'job7', 'job8' >
> >
>
> > 'job9', 'job10'
>
>
>
> The idea "popped" in my mind while thinking about this quest= ion.
>
> http://stackoverflow.com= /questions/18121416/right-split-a-string-into-groups-of-3/18122084
>
> I founded the list comprehensions solutions kind of cumbersome and tho= ught that there should be a simple way to do this kind of stuff.
>
> --
>
> http://mail.python.org/mailman/listinfo/python-list
>
>
>
>
>
> Still seems a bit like a solution lookin= g for a problem to me.
>
>
>
> Why would you want to take four items at a time for a job from an arbi= trary part of a list? =A0I agree splitting a string into groups of three lo= oks a bit cumbersome in the example you've given, but a generator could= be written quite easily, and would almost certainly be quicker than trying= to alter the list in place.
>
>
>
> Best wishes,
>
>
> N.

You are perfectly right. But I looked at it more like an improvement = in the style of writing solutions and also a natural option because slices = are highly present all over in python.


I wasn't knocking it. =A0I was just trying to= think it through.=A0
--047d7b677442ca6cde04e3701e02--