def pprint_list(l, c, pad=1, indent=0):
    if c == -1:
        try:
            rows, columns = get_console_dimensions()

            table_n = None
            for c in xrange(1, min(columns / (pad + 1), len(l))):
                table = table_n
                table_n = [l[c * i:c * i + c] for i in range(1 + len(l) / c)]
                table_n[-1].extend([''] * (c - len(table_n[-1])))
                sumwid = indent
                for i in xrange(c):
                    sumwid += get_max_width(table_n, i)
                sumwid += pad * c
                if sumwid > columns:
                    if not table:
                        table = table_n
                    break
        except Exception:
            return pprint_list(l, 1, pad, indent)
    else:
        table = [l[c * i:c * i + c] for i in range(1 + len(l) / c)]
        table_n[-1].extend([''] * (c - len(table_n[-1])))

    return pprint_table(table, pad, indent)

# -------------------------------------------------
Pretty prints a list as table and returns string.
dataset/ETHPy150Open ooici/pyon/pyon/container/shell_api.py/pprint_list