def partition(pred, iterable):
    """Partition an iterable.

    Arguments
    ---------
    pred     : function
               A function that takes an element of the iterable and returns
               a boolen indicating to which partition it belongs
    iterable : iterable

    Returns
    -------
    A two-tuple of lists with the first list containing the elements on which
    the predicate indicated False and the second list containing the elements
    on which the predicate indicated True.

    Note that, unlike the recipe which returns generators, this version
    returns lists.
    """
    pos, neg = [], []
    pos_append, neg_append = pos.append, neg.append
    for elem in iterable:
        if pred(elem):
            pos_append(elem)
        else:
            neg_append(elem)
    return neg, pos
Partition an iterable.

    Arguments
    ---------
    pred     : function
               A function that takes an element of the iterable and returns
               a boolen indicating to which partition it belongs
    iterable : iterable

    Returns
    -------
    A two-tuple of lists with the first list containing the elements on which
    the predicate indicated False and the second list containing the elements
    on which the predicate indicated True.

    Note that, unlike the recipe which returns generators, this version
    returns lists.