In[7]: from itertools import groupby
In[8]: split_by = lambda pred: lambda seq: tuple(list(items) for _,items in groupby(sorted(seq, key=pred), key=pred))
In[10]: evens, odds = split_by(lambda x: x % 2)(range(10))
In[11]: evens
Out[11]: [0, 2, 4, 6, 8]
In[12]: odds
Out[12]: [1, 3, 5, 7, 9]