split up a list by condition?

Grooooops JOHNWUN at aol.com
Tue Jun 7 15:58:17 EDT 2005


> vees, cons = [], []
> [(vees, cons)[ch in vocals].append(ch) for ch in wlist]

Wow, that's horribly twisted Reinhold...
I spent about an hour last night trying something similar, to no end...
:)

Neat tricks people...
I like Duncan's use of "or" to solve it.
I didn't see that in the python docs on list comprehension.
Very cool.

There is a special place in my heart for obfuscated Python,
but of course, not in production code if there is a clearer solution
available.




More information about the Python-list mailing list