Modified split() to include padding
    See http://code.activestate.com/lists/python-ideas/3366/

    :attr value: see str.split()
    :attr sep: see str.split()
    :attr maxsplit: see str.split()
    :attr pad: Value to use for padding maxsplit

    >>> padded_split('text/html', ';', 1)
    ['text/html', None]
    >>> padded_split('text/html;q=1', ';', 1)
    ['text/html', 'q=1']
    >>> padded_split('text/html;a=1;b=2', ';', 1)
    ['text/html', 'a=1;b=2']
    >>> padded_split('text/html', ';', 1, True)
    ['text/html', True]
    >>> padded_split('text/html;a=1;b=2', ';', 2)
    ['text/html', 'a=1', 'b=2']
    >>> padded_split('text/html;a=1', ';', 2)
    ['text/html', 'a=1', None]

def padded_split(value, sep, maxsplit=None, pad=None):
    """
    Modified split() to include padding
    See http://code.activestate.com/lists/python-ideas/3366/

    :attr value: see str.split()
    :attr sep: see str.split()
    :attr maxsplit: see str.split()
    :attr pad: Value to use for padding maxsplit

    >>> padded_split('text/html', ';', 1)
    ['text/html', None]
    >>> padded_split('text/html;q=1', ';', 1)
    ['text/html', 'q=1']
    >>> padded_split('text/html;a=1;b=2', ';', 1)
    ['text/html', 'a=1;b=2']
    >>> padded_split('text/html', ';', 1, True)
    ['text/html', True]
    >>> padded_split('text/html;a=1;b=2', ';', 2)
    ['text/html', 'a=1', 'b=2']
    >>> padded_split('text/html;a=1', ';', 2)
    ['text/html', 'a=1', None]
    """
    result = value.split(sep, maxsplit)
    if maxsplit is not None:
        result.extend(
            [pad] * (1+maxsplit-len(result)))
    return result