Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!eweka.nl!lightspeed.eweka.nl!194.109.133.81.MISMATCH!newsfeed.xs4all.nl!newsfeed2.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.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject:PEP': 0.07; 'cc:addr:python-list': 0.11; 'exists,': 0.16; 'from:addr:pobox.com': 0.16; 'from:addr:skip': 0.16; 'iterator': 0.16; 'itertools': 0.16; 'stuff.': 0.16; 'subclass': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'thu,': 0.19; 'seems': 0.21; 'example': 0.22; 'aug': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'skip': 0.24; 'initial': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'mix': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'subject:from': 0.34; 'could': 0.34; 'basic': 0.35; 'something': 0.35; 'case,': 0.35; 'subject:lists': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'module.': 0.36; 'doing': 0.36; 'method': 0.36; 'useful': 0.36; 'list': 0.37; 'list.': 0.37; "couldn't": 0.39; 'structure': 0.39; 'to:addr:gmail.com': 0.65; 'jobs': 0.68; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=mHcjZDWab8JacVmOURua2DvB2jWBGpFRWgfTeNOF9y8=; b=xhWnrc54C7w1iT4LIRDy5VlSuc0wNFs4tIKB/+HgD8J3pwWWQkIYri2xOFbyXbkfeM n1jZAm8wkYDCO25npmOmuYzsXzbM9SgRcaDORlZhX/AprjjgLqNB4egRqOd2ah6gOZxE YPUScxkVIs+tgbeS9gILNv3nDSn9M6jlyKjG8zmW4O3yCHs3/Bf8AgQk6p6jhOuFHch+ lg+sDzZKNXNAUYPL7E8aVVrTrozebIOx1c3YHKvv7YhNAaQ5zhU18to+7PYAUhXIx4dc rbJxopZ3FPg82ctpXug3CoUKq8jIvrbW9TkdQIbnqxLBCd5Qkoy9Sbabph82Q1mKCV4M 1svg== MIME-Version: 1.0 X-Received: by 10.52.34.40 with SMTP id w8mr2751157vdi.7.1375971658837; Thu, 08 Aug 2013 07:20:58 -0700 (PDT) Sender: skip.montanaro@gmail.com In-Reply-To: References: <531d89a8-61e1-4117-b4cc-f02b3be30bb9@googlegroups.com> Date: Thu, 8 Aug 2013 09:20:58 -0500 X-Google-Sender-Auth: 2C-ajpWXaAyfx7fIFue2T4PJ914 Subject: Re: Suggestion: PEP for popping slices from lists From: Skip Montanaro To: Neatu Ovidiu Content-Type: text/plain; charset=UTF-8 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: 14 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1375973493 news.xs4all.nl 15988 [2001:888:2000:d::a6]:41692 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:52201 On Thu, Aug 8, 2013 at 6:40 AM, Neatu Ovidiu wrote: > 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', 'job5', 'job6', 'job7', 'job8', 'job9', 'job10'] > while jobs: > print jobs.pop_slice(0,4) My initial reaction to this is that you want to infer structure where none exists, so why not make the structure explicit? In any case, couldn't you subclass the list type and add a pop_slice method to do what you want? I'm not an iterator maven, but this also seems like something you could mix up from something in the itertools module. Skip