import itertools


def split_and_pad(s, sep, nsplit, pad=None):
    """ Splits string s on sep, up to nsplit times.
        Returns the results of the split, pottentially padded with
        additional items, up to a total of nsplit items.
    """
    l = s.split(sep, nsplit)
    return itertools.chain(l, itertools.repeat(None, nsplit+1-len(l)))