(self, printer, rowsep='\n', colsep=', ', align='right')
return rowsep.join(res)
r"""
        String form of Matrix as a table.

        ``printer`` is the printer to use for on the elements (generally
        something like StrPrinter())

        ``rowsep`` is the string used to separate rows (by default a newline).

        ``colsep`` is the string used to separate columns (by default ', ').

        ``align`` defines how the elements are aligned. Must be one of 'left',
        'right', or 'center'.  You can also use '<', '>', and '^' to mean the
        same thing, respectively.

        This is used by the string printer for Matrix.

        Examples
        ========

        >>> from sympy import Matrix
        >>> from sympy.printing.str import StrPrinter
        >>> M = Matrix([[1, 2], [-33, 4]])
        >>> printer = StrPrinter()
        >>> M.table(printer)
        '[  1, 2]\n[-33, 4]'
        >>> print(M.table(printer))
        [  1, 2]
        [-33, 4]
        >>> print(M.table(printer, rowsep=',\n'))
        [  1, 2],
        [-33, 4]
        >>> print('[%s]' % M.table(printer, rowsep=',\n'))
        [[  1, 2],
        [-33, 4]]
        >>> print(M.table(printer, colsep=' '))
        [  1 2]
        [-33 4]
        >>> print(M.table(printer, align='center'))
        [ 1 , 2]
        [-33, 4]
r"""
        String form of Matrix as a table.
r String form of Matrix as a table .
def table(self, printer, rowsep='\n', colsep=', ', align='right'):
        r"""
        String form of Matrix as a table.

        ``printer`` is the printer to use for on the elements (generally
        something like StrPrinter())

        ``rowsep`` is the string used to separate rows (by default a newline).

        ``colsep`` is the string used to separate columns (by default ', ').

        ``align`` defines how the elements are aligned. Must be one of 'left',
        'right', or 'center'.  You can also use '<', '>', and '^' to mean the
        same thing, respectively.

        This is used by the string printer for Matrix.

        Examples
        ========

        >>> from sympy import Matrix
        >>> from sympy.printing.str import StrPrinter
        >>> M = Matrix([[1, 2], [-33, 4]])
        >>> printer = StrPrinter()
        >>> M.table(printer)
        '[  1, 2]\n[-33, 4]'
        >>> print(M.table(printer))
        [  1, 2]
        [-33, 4]
        >>> print(M.table(printer, rowsep=',\n'))
        [  1, 2],
        [-33, 4]
        >>> print('[%s]' % M.table(printer, rowsep=',\n'))
        [[  1, 2],
        [-33, 4]]
        >>> print(M.table(printer, colsep=' '))
        [  1 2]
        [-33 4]
        >>> print(M.table(printer, align='center'))
        [ 1 , 2]
        [-33, 4]
        """
        # Handle zero dimensions:
        if self.rows == 0 or self.cols == 0:
            return '[]'
        # Build table of string representations of the elements
        res = []
        # Track per-column max lengths for pretty alignment
        maxlen = [0] * self.cols
        for i in range(self.rows):
            res.append([])
            for j in range(self.cols):
                s = printer._print(self[i,j])
                res[-1].append(s)
                maxlen[j] = max(len(s), maxlen[j])
        # Patch strings together
        align = {
            'left': str.ljust,
            'right': str.rjust,
            'center': str.center,
            '<': str.ljust,
            '>': str.rjust,
            '^': str.center,
            }[align]
        for i, row in enumerate(res):
            for j, elem in enumerate(row):
                row[j] = align(elem, maxlen[j])
            res[i] = "[" + colsep.join(row) + "]"
        return rowsep.join(res)
def table ( self , printer , rowsep = '\n' , colsep = ', ' , align = 'right' ) : # Handle zero dimensions: if self . rows == 0 or self . cols == 0 : return '[]' # Build table of string representations of the elements res = [ ] # Track per-column max lengths for pretty alignment maxlen = [ 0 ] * self . cols for i in range ( self . rows ) : res . append ( [ ] ) for j in range ( self . cols ) : s = printer . _print ( self [ i , j ] ) res [ - 1 ] . append ( s ) maxlen [ j ] = max ( len ( s ) , maxlen [ j ] ) # Patch strings together align = { 'left' : str . ljust , 'right' : str . rjust , 'center' : str . center , '<' : str . ljust , '>' : str . rjust , '^' : str . center , } [ align ] for i , row in enumerate ( res ) : for j , elem in enumerate ( row ) : row [ j ] = align ( elem , maxlen [ j ] ) res [ i ] = "[" + colsep . join ( row ) + "]" return rowsep . join ( res )