Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.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.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'subject:two': 0.07; '[],': 0.09; 'subject:into': 0.09; 'cc:addr:python-list': 0.11; 'subject:based': 0.16; 'wrote:': 0.18; 'version.': 0.19; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '>': 0.26; 'header:In-Reply-To:1': 0.27; 'subject:list': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'could': 0.34; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'skip:o 20': 0.38; 'sure': 0.39; '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=unaMFcN2ECWmXUzOZiOIAczQA6HJMBRBZVfC23mF2DM=; b=DJQOAeppJnvT1jSxidDVcYMRVVSJPz45sKFO2sexb1YAolfgZ4slGsJfCe+vpg6FuS GARo38TSUjS5W2Mu8R4hilpyox0BSefK5PUeEqkFL5Kp+OhRXoZuHYHwjgQ39Ok1zgrH ZLe2H8/yRo8ybFNiNaf24Irj5vS69kXIQ+1eY0N1UuqxKugE8JSGszUs34nJWsB4xSq3 Ao2PVXWe/snMFFDbR0stlSqg3z04vHW9B8gLwfE/p2mFiTdKpMbMY4DopW0eS3/iwi2W 8569zroGpgbvp2qdFXCLrPVDZ7l0HS/lP4PHReLUIPlGwWliauXkf1ZYJFGuEybmgz/z mVHg== MIME-Version: 1.0 X-Received: by 10.224.106.195 with SMTP id y3mr13886884qao.35.1370905726238; Mon, 10 Jun 2013 16:08:46 -0700 (PDT) In-Reply-To: References: Date: Tue, 11 Jun 2013 00:08:46 +0100 Subject: Re: Split a list into two parts based on a filter? From: =?ISO-8859-1?Q?F=E1bio_Santos?= To: Roel Schroeven Content-Type: multipart/alternative; boundary=20cf3074b33ad547c804ded4dce5 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: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1370905734 news.xs4all.nl 15975 [2001:888:2000:d::a6]:35318 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:47616 --20cf3074b33ad547c804ded4dce5 Content-Type: text/plain; charset=ISO-8859-1 On 10 Jun 2013 23:54, "Roel Schroeven" wrote: > > You could do something like: > > new_songs, old_songs = [], [] > [(new_songs if s.is_new() else old_songs).append(s) for s in songs] > > But I'm not sure that that's any better than the long version. This is so beautiful! --20cf3074b33ad547c804ded4dce5 Content-Type: text/html; charset=ISO-8859-1


On 10 Jun 2013 23:54, "Roel Schroeven" <roel@roelschroeven.net> wrote:
>
> You could do something like:
>
> new_songs, old_songs = [], []
> [(new_songs if s.is_new() else old_songs).append(s) for s in songs]
>
> But I'm not sure that that's any better than the long version.

This is so beautiful!

--20cf3074b33ad547c804ded4dce5--