def transposed_matrix(matrix, filler=None, row_type=list, matrix_type=list, value_type=None):
matrix_type = matrix_type or type(matrix)<EOL>try:<EOL><INDENT>row_type = row_type or type(matrix[<NUM_LIT:0>])<EOL><DEDENT>except (IndexError, ValueError, AttributeError, TypeError):<EOL><INDENT>pass<EOL><DEDENT>if not row_type or row_type is None:<EOL><INDENT>row_type = list<EOL><DEDENT>try:<EOL><INDENT>if matrix[<NUM_LIT:0>][<NUM_LIT:0>] is None:<EOL><INDENT>value_type = value_type or float<EOL><DEDENT>else:<EOL><INDENT>value_type = value_type or type(matrix[<NUM_LIT:0>][<NUM_LIT:0>]) or float<EOL><DEDENT><DEDENT>except (IndexError, ValueError, AttributeError, TypeError):<EOL><INDENT>pass<EOL><DEDENT>if not value_type or value_type is None:<EOL><INDENT>value_type = float<EOL><DEDENT>N = len(matrix)<EOL>Ms = [len(row) for row in matrix]<EOL>M = <NUM_LIT:0> if not Ms else max(Ms)<EOL>ans = []<EOL>for j in range(M):<EOL><INDENT>ans += [row_type([filler] * N)]<EOL>for i in range(N):<EOL><INDENT>try:<EOL><INDENT>ans[j][i] = value_type(matrix[i][j])<EOL><DEDENT>except IndexError:<EOL><INDENT>ans[j][i] = filler<EOL><DEDENT>except TypeError:<EOL><INDENT>ans[j][i] = filler<EOL><DEDENT><DEDENT><DEDENT>return matrix_type(ans) if isinstance(ans[<NUM_LIT:0>], row_type) else matrix_type([row_type(row) for row in ans])<EOL>
Like numpy.transposed, evens up row (list) lengths that aren't uniform, filling with None.

    Also, makes all elements a uniform type (default=type(matrix[0][0])),
    except for filler elements.

    TODO: add feature to delete None's at the end of rows so that transpose(transpose(LOL)) = LOL

    >>> transposed_matrix([[1, 2], [3, 4, 5], [6]])
    [[1, 3, 6], [2, 4, None], [None, 5, None]]
    >>> transposed_matrix(transposed_matrix([[1, 2], [3, 4, 5], [6]]))
    [[1, 2, None], [3, 4, 5], [6, None, None]]
    >>> transposed_matrix([[], [1, 2, 3], [4]])  # empty first row forces default value type (float)
    [[None, 1.0, 4.0], [None, 2.0, None], [None, 3.0, None]]
    >>> transposed_matrix(transposed_matrix([[], [1, 2, 3], [4]]))
    [[None, None, None], [1.0, 2.0, 3.0], [4.0, None, None]]
    >>> x = transposed_matrix([range(4),[4,5]])
    >>> x
    [[0, 4], [1, 5], [2, None], [3, None]]
    >>> transposed_matrix(x)
    [[0, 1, 2, 3], [4, 5, None, None]]
    >>> transposed_matrix([[1,2],[1],[1,2,3]])
    [[1, 1, 1], [2, None, 2], [None, None, 3]]