Extracting elements over multiple lists?

John Gordon gordon at panix.com
Mon Nov 7 13:22:00 EST 2011


In <cf007146-3a08-44c4-bf01-d1a9253c83e3 at o19g2000vbk.googlegroups.com> JoeM <josephmeiring at gmail.com> writes:

> Thanks guys, I was just looking for a one line solution instead of a
> for loop if possible. Why do you consider

> [x.remove(x[0]) for x in [a,b,c]]

> cheating? It seems compact and elegant enough for me.

I wouldn't call it cheating, but that solution does a fair bit of
unneccessary work (creating a list comprehension that is never used.)

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon at panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"




More information about the Python-list mailing list