def columnize(items, row_first=False, separator='  ', displaywidth=80, spread=False):
 if (not items):
  return '\n'
 (matrix, info) = compute_item_matrix(items, row_first=row_first, separator_size=len(separator), displaywidth=displaywidth)
 if spread:
  separator = separator.ljust(int(info['optimal_separator_width']))
 fmatrix = [filter(None, x) for x in matrix]
 sjoin = (lambda x: separator.join([y.ljust(w, ' ') for (y, w) in zip(x, info['column_widths'])]))
 return ('\n'.join(map(sjoin, fmatrix)) + '\n')

def columnize ( items , row_first = False , separator = '  ' , displaywidth = 80 , spread = False ) : if ( not items ) : return '\n' ( matrix , info ) = compute_item_matrix ( items , row_first = row_first , separator_size = len ( separator ) , displaywidth = displaywidth ) if spread : separator = separator . ljust ( int ( info [ 'optimal_separator_width' ] ) ) fmatrix = [ filter ( None , x ) for x in matrix ] sjoin = ( lambda x : separator . join ( [ y . ljust ( w , ' ' ) for ( y , w ) in zip ( x , info [ 'column_widths' ] ) ] ) ) return ( '\n' . join ( map ( sjoin , fmatrix ) ) + '\n' )
transform a list of strings into a single string with columns .