return tuple([z[1] for z in y[1]] for y in itertools.groupby(sorted((bool(
    pred(x)), x) for x in seq), operator.itemgetter(0)))
elegantly splitting a list (or dict) into two via some arbitrary function in python