Split a list into two parts based on a filter?

Jonas Geiregat jonas at geiregat.org
Tue Jun 11 02:47:23 EDT 2013


On 11 Jun 2013, at 01:08, Fábio Santos wrote:

> 
> On 10 Jun 2013 23:54, "Roel Schroeven" <roel at 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!
> 
> 

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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130611/9d9b7e8e/attachment.html>


More information about the Python-list mailing list