Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #52201

Re: Suggestion: PEP for popping slices from lists

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 <skip.montanaro@gmail.com>
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 <efa20d58-0791-4375-a8aa-a9394b3ff51e@googlegroups.com>
References <dac4873d-4111-4880-9ce5-80f4ecf11685@googlegroups.com> <mailman.345.1375956533.1251.python-list@python.org> <531d89a8-61e1-4117-b4cc-f02b3be30bb9@googlegroups.com> <mailman.347.1375960376.1251.python-list@python.org> <efa20d58-0791-4375-a8aa-a9394b3ff51e@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 <skip@pobox.com>
To Neatu Ovidiu <neatuovi@gmail.com>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.353.1375973493.1251.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Thu, Aug 8, 2013 at 6:40 AM, Neatu Ovidiu <neatuovi@gmail.com> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Suggestion: PEP for popping slices from lists Neatu Ovidiu Gabriel <neatuovi@gmail.com> - 2013-08-08 02:45 -0700
  Re: Suggestion: PEP for popping slices from lists Peter Otten <__peter__@web.de> - 2013-08-08 12:07 +0200
    Re: Suggestion: PEP for popping slices from lists Neatu Ovidiu <neatuovi@gmail.com> - 2013-08-08 03:38 -0700
      Re: Suggestion: PEP for popping slices from lists Nicholas Cole <nicholas.cole@gmail.com> - 2013-08-08 12:12 +0100
        Re: Suggestion: PEP for popping slices from lists Neatu Ovidiu <neatuovi@gmail.com> - 2013-08-08 04:40 -0700
          Re: Suggestion: PEP for popping slices from lists Skip Montanaro <skip@pobox.com> - 2013-08-08 09:20 -0500
        Re: Suggestion: PEP for popping slices from lists Neatu Ovidiu <neatuovi@gmail.com> - 2013-08-08 04:44 -0700
          Re: Suggestion: PEP for popping slices from lists Neatu Ovidiu <neatuovi@gmail.com> - 2013-08-08 04:50 -0700
            Re: Suggestion: PEP for popping slices from lists Nicholas Cole <nicholas.cole@gmail.com> - 2013-08-08 14:08 +0100
              Re: Suggestion: PEP for popping slices from lists Neatu Ovidiu <neatuovi@gmail.com> - 2013-08-08 06:32 -0700
                Re: Suggestion: PEP for popping slices from lists Nicholas Cole <nicholas.cole@gmail.com> - 2013-08-08 15:03 +0100
          Re: Suggestion: PEP for popping slices from lists Terry Reedy <tjreedy@udel.edu> - 2013-08-08 16:03 -0400
          Re: Suggestion: PEP for popping slices from lists Joshua Landau <joshua@landau.ws> - 2013-08-08 22:32 +0100
          Re: Suggestion: PEP for popping slices from lists Tim Chase <python.list@tim.thechases.com> - 2013-08-08 16:50 -0500
          Re: Suggestion: PEP for popping slices from lists Terry Reedy <tjreedy@udel.edu> - 2013-08-08 18:10 -0400

csiph-web