Sequence splitting

Paul Rubin http
Fri Jul 3 00:58:22 EDT 2009


"Pablo Torres N." <tn.pablo at gmail.com> writes:
> def split(seq, func=bool):
>  	t = filter(func, seq)
>  	f = filter(lambda x: not func(x), seq)
>  	return list(t), list(f)

That is icky--you're calling func (which might be slow) twice instead
of once on every element of the seq.



More information about the Python-list mailing list