def partition(space, nparts):
    """
    create balanced partitions from an iterable space.  This method preserves
    contiguous order.

    kudos:
    http://code.activestate.com/recipes/425397-split-a-list-into-roughly-equal-sized-pieces/
    """
    n = len(space)
    b = 0
    ret = list()
    for k in range(nparts):
        q, r = divmod(n - k, nparts)
        a, b = b, b + q + (r != 0)
        ret.append(space[a:b])
    return ret
