Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed3.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.117 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.84; '*S*': 0.07; 'explicit': 0.07; 'subject:two': 0.07; '[],': 0.09; 'snippet': 0.09; 'subject:into': 0.09; 'pythonic': 0.16; 'subject:based': 0.16; 'all.': 0.16; 'wrote:': 0.18; 'version.': 0.19; "i've": 0.25; '>': 0.26; 'header:In-Reply-To:1': 0.27; 'subject:list': 0.30; "i'm": 0.30; 'code': 0.31; 'implicit': 0.31; 'could': 0.34; 'something': 0.35; 'but': 0.35; 'subject:?': 0.36; 'skip:o 20': 0.38; 'to:addr :python-list': 0.38; 'does': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'header:Message-Id:1': 0.63; 'received:195.238': 0.84; 'received:195.238.6': 0.84; 'received:belgacom.be': 0.84; 'received:isp.belgacom.be': 0.84; 'version.this': 0.84; '2013,': 0.91; 'received:172.31': 0.91; '2013': 0.98 X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnkDAObGtlFbtJnD/2dsb2JhbAANTIM5tkiIRgMBgRGDDgkBAQEDAYEJCwMBFC5XGYgHpxySeo5YZhaCaWEDrBM From: Jonas Geiregat Mime-Version: 1.0 (Apple Message framework v1283) Content-Type: multipart/alternative; boundary="Apple-Mail=_4B166157-2681-4A74-A858-D08DEE1AD8D4" Subject: Re: Split a list into two parts based on a filter? Date: Tue, 11 Jun 2013 08:47:23 +0200 In-Reply-To: To: python-list@python.org References: X-Mailer: Apple Mail (2.1283) 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: 58 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1370933317 news.xs4all.nl 15927 [2001:888:2000:d::a6]:49632 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:47642 --Apple-Mail=_4B166157-2681-4A74-A858-D08DEE1AD8D4 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=iso-8859-1 On 11 Jun 2013, at 01:08, F=E1bio Santos wrote: >=20 > On 10 Jun 2013 23:54, "Roel Schroeven" wrote: > > > > You could do something like: > > > > new_songs, old_songs =3D [], [] > > [(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. >=20 > This is so beautiful! >=20 >=20 I must disagree , this is unreadable and in my honor opinion not = Pythonic at all. I've learned it's always better to be explicit then implicit, and this = snippet of code does a lot in an implicit way. --Apple-Mail=_4B166157-2681-4A74-A858-D08DEE1AD8D4 Content-Transfer-Encoding: quoted-printable 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 =3D [], []
> [(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!



I must disagree = , this is unreadable and in my honor opinion not Pythonic at = all.
I've learned it's always better to be explicit then = implicit, and this snippet of code does a lot in an implicit = way.

= --Apple-Mail=_4B166157-2681-4A74-A858-D08DEE1AD8D4--