def aligned_output(cols, indent, tab_size=4):
    """
    Pretty printing function to output tabular data containing multiple
    columns of text, left-aligned.

    The first column is aligned at an indentation of "indent". Each
    successive column is aligned on a suitable multiple of the "tab_size"
    with spaces for all indentation.

    "cols" is assumed to be a list of columns, with each column holding
    an equal length list of string values.
    """
    # Check the input data
    ncols = len(cols)
    if ncols == 0: return ""
    nrows = len(cols[0])
    if nrows == 0: return ""

    # Work out the indentations and widths of each column
    indents = [ indent ]
    widths = []
    for col in range(1, ncols):
        width = max(len(x) for x in cols[col-1])
        indents.append(((indents[col-1]+width+tab_size) / tab_size) * tab_size)
        widths.append(indents[col] - indents[col-1])

    # Now output the actual tabular values
    result = ""
    for row in range(0, nrows):
        if row > 0:
            result += ",\n" + (" " * indent)
        if len(cols) > 1:
            for col in range(0, ncols-1):
                result += cols[col][row].ljust(widths[col])
        result += cols[-1][row]
    return result