def pprinttable(rows):
if not rows:<EOL><INDENT>return<EOL><DEDENT>if hasattr(rows[<NUM_LIT:0>], '<STR_LIT>'):  <EOL><INDENT>headers = rows[<NUM_LIT:0>]._fields<EOL><DEDENT>else:<EOL><INDENT>headers = ["<STR_LIT>".format(i) for i in range(len(rows[<NUM_LIT:0>]))]<EOL><DEDENT>lens = [len(s) for s in headers]<EOL>for row in rows:<EOL><INDENT>for i in range(len(rows[<NUM_LIT:0>])):<EOL><INDENT>slenght = len("<STR_LIT:{}>".format(row[i]))<EOL>if slenght > lens[i]:<EOL><INDENT>lens[i] = slenght<EOL><DEDENT><DEDENT><DEDENT>formats = []<EOL>hformats = []<EOL>for i in range(len(rows[<NUM_LIT:0>])):<EOL><INDENT>if isinstance(rows[<NUM_LIT:0>][i], int):<EOL><INDENT>formats.append("<STR_LIT>" % lens[i])<EOL><DEDENT>else:<EOL><INDENT>formats.append("<STR_LIT>" % lens[i])<EOL><DEDENT>hformats.append("<STR_LIT>" % lens[i])<EOL><DEDENT>pattern = "<STR_LIT>".join(formats)<EOL>hpattern = "<STR_LIT>".join(hformats)<EOL>separator = "<STR_LIT>".join(['<STR_LIT:->' * n for n in lens])<EOL>s = "<STR_LIT>"<EOL>s += separator + '<STR_LIT:\n>'<EOL>s += (hpattern % tuple(headers)) + '<STR_LIT:\n>'<EOL>s += separator + '<STR_LIT:\n>'<EOL>def f(t):<EOL><INDENT>return "<STR_LIT:{}>".format(t) if isinstance(t, basestring) else t<EOL><DEDENT>for line in rows:<EOL><INDENT>s += pattern % tuple(f(t) for t in line) + '<STR_LIT:\n>'<EOL><DEDENT>s += separator + '<STR_LIT:\n>'<EOL>return s<EOL>
Returns a pretty ascii table from tuples

    If namedtuple are used, the table will have headers