Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(1)  |  Call(1)  |  Derive(0)  |  Import(0)
Print a number of items in column format.

        def print_columns(items, linelen=70, spacing=2):
    """
    Print a number of items in column format.
    """

    maxlen = max(len(text) for text in items)
    columns = max(linelen / (maxlen + spacing), 1)
    padding = " " * spacing

    count = 0
    while count < len(items):
        print items[count].ljust(maxlen) + padding,
        count += 1
        if count % columns == 0:
            print

    if count % columns != 0:
        print
        


src/p/y/pyditz-0.6/tests/test-util.py   pyditz(Download)
    print
    names = "fred brian derek tarquin ermintrude cyril"
    util.print_columns(names.split(), linelen=45)
 
    print