def print_table(table, header=None, sep='   ', numfmt='%g'):
    """Print a list of lists as a table, so that columns line up nicely.
    header, if specified, will be printed as the first row.
    numfmt is the format for all numbers; you might want e.g. '%6.2f'.
    (If you want different formats in different columns, don't use print_table.)
    sep is the separator between columns."""
    justs = [if_(isnumber(x), 'rjust', 'ljust') for x in table[0]]
    if header:
        table = [header] + table
    table = [[if_(isnumber(x), lambda: numfmt % x, lambda: x) for x in row]
             for row in table]
    maxlen = lambda seq: max(map(len, seq))
    sizes = map(maxlen, zip(*[map(str, row) for row in table]))
    for row in table:
        print sep.join(getattr(str(x), j)(size)
                       for (j, size, x) in zip(justs, sizes, row))
def print_table(table, header=None, sep='   ', numfmt='%g'):
    """Print a list of lists as a table, so that columns line up nicely.
    header, if specified, will be printed as the first row.
    numfmt is the format for all numbers; you might want e.g. '%6.2f'.
    (If you want different formats in different columns, don't use print_table.)
    sep is the separator between columns."""
    justs = [if_(isnumber(x), 'rjust', 'ljust') for x in table[0]]
    if header:
        table = [header] + table
    table = [[if_(isnumber(x), lambda: numfmt % x, lambda: x) for x in row]
             for row in table]
    maxlen = lambda seq: max(map(len, seq))
    sizes = map(maxlen, zip(*[map(str, row) for row in table]))
    for row in table:
        print sep.join(getattr(str(x), j)(size)
                       for (j, size, x) in zip(justs, sizes, row))
def print_table ( table , header = None , sep = '   ' , numfmt = '%g' ) : justs = [ if_ ( isnumber ( x ) , 'rjust' , 'ljust' ) for x in table [ 0 ] ] if header : table = [ header ] + table table = [ [ if_ ( isnumber ( x ) , lambda : numfmt % x , lambda : x ) for x in row ] for row in table ] maxlen = lambda seq : max ( map ( len , seq ) ) sizes = map ( maxlen , zip ( * [ map ( str , row ) for row in table ] ) ) for row in table : print sep . join ( getattr ( str ( x ) , j ) ( size ) for ( j , size , x ) in zip ( justs , sizes , row ) )
Print a list of lists as a table, so that columns line up nicely.
    header, if specified, will be printed as the first row.
    numfmt is the format for all numbers; you might want e.g. '%6.2f'.
    (If you want different formats in different columns, don't use print_table.)
    sep is the separator between columns.
Print a list of lists as a table so that columns line up nicely . header if specified will be printed as the first row . numfmt is the format for all numbers ; you might want e . g . %6 . 2f . ( If you want different formats in different columns don t use print_table . ) sep is the separator between columns .