def group(seq, groupSize, noneFill=True):
    'Groups a given sequence into sublists of length groupSize.'
    ret = []
    L = []
    i = groupSize
    for elt in seq:
        if (i > 0):
            L.append(elt)
        else:
            ret.append(L)
            i = groupSize
            L = []
            L.append(elt)
        i -= 1
    if L:
        if noneFill:
            while (len(L) < groupSize):
                L.append(None)
        ret.append(L)
    return ret
Groups a given sequence into sublists of length groupSize.
def group(seq, groupSize, noneFill=True):
    
    ret = []
    L = []
    i = groupSize
    for elt in seq:
        if (i > 0):
            L.append(elt)
        else:
            ret.append(L)
            i = groupSize
            L = []
            L.append(elt)
        i -= 1
    if L:
        if noneFill:
            while (len(L) < groupSize):
                L.append(None)
        ret.append(L)
    return ret