split up a list by condition?

Reinhold Birkenfeld reinhold-birkenfeld-nospam at wolke7.net
Mon Jun 6 16:22:24 EDT 2005


Hi,

while writing my solution for "The python way?", I came across this fragment:

    vees = [c for c in wlist[::-1] if c in vocals]
    cons = [c for c in wlist[::-1] if c not in vocals]

So I think: Have I overlooked a function which splits up a sequence into two,
based on a condition? Such as

vees, cons = split(wlist[::-1], lambda c: c in vocals)

Reinhold



More information about the Python-list mailing list