def filtersplit(p, iterable):
    """
    filtersplit(p, iter) -> ifilter(p, iter), ifilterfalse(p, iter)

    >>> iseven = lambda x: (x % 2) == 0
    >>> filtersplit(iseven, [0, 1, 2, 3, 4])
    ([0, 2, 4], [1, 3])
    """
    t, f = [], []
    if p is None:
        p = bool
    for i in iterable:
        if p(i):
            t.append(i)
        else:
            f.append(i)
    return t, f
