schickb <[email protected]> writes: > def split(seq, func=None): > if func is None: > func = bool > t, f = [], [] > for item in seq: > if func(item): > t.append(item) > else: > f.append(item) > return (t, f)
untested:
def split(seq, func=bool):
xs = zip(seq, itertools.imap(func, seq))
t = list(x for (x,y) in xs if y)
f = list(x for (x,y) in xs if not y)
return (t, f)
--
http://mail.python.org/mailman/listinfo/python-list
