title: pretty printer with Python?
body: <p>I have a list of labels, and data as follows.</p>
  
  <pre>
  ['id', 'Version', 'chip_name', 'xversion', 'device', 'opt_param', 'place_effort']
  [1, 1.0, u'virtex2', u'xilinx11.5', u'xc5vlx50', u'Speed', u'High']
  </pre>
  
  <p>I need to print them into console. And for this, I'm iterating over the list, and print out each element with a tab ('\t').</p>
  
  <p>But, unfortunately, the result is not so pretty. </p>
  
  <pre>
  
  number of data 1 and number of column 7
  id      Version     chip_name       xversion        device      opt_param       place_effort        
  1       1.0     virtex2     xilinx11.5      xc5vlx50        Speed       High        
  </pre>
  
  <p>The string length of label and data is quite variable, and it's not aligned well.</p>
  
  <p>Is there any  solution to this problem with Python?</p>
  
  <h2>ADDED</h2>
  
  <p>Hepled by Mike DeSimone's answer, I could make the pretty printer that I can use for my purposes. The valueResults are a list of duple. </p>
  
  <pre><code>    labels = queryResult.names
      valueResults = queryResult.result
  
      # get the maximum width
      allData = valueResults
      allData.insert(0,labels)
      transpose = zip(*valueResults) # remove the sequence as a parameter
      #print transpose
      for value in transpose:
          # value is integer/float/unicode/str, so make it length of str
          newValue = [len(str(i)) for i in value]
          columnWidth = max(newValue)
          columnWidths.append(columnWidth)
          dividers.append('-' * columnWidth)
          dblDividers.append('=' * columnWidth)
          label = value[0]
          paddedLabels.append(label.center(columnWidth))
  
      paddedString = ""
  
      for values in valueResults[1:]:
          paddedValue = []
          for i, value in enumerate(values):
              svalue = str(value)
              columnWidth = columnWidths[i]
              paddedValue.append(svalue.center(columnWidth))
          paddedString += '| ' + ' | '.join(paddedValue) + ' |' + '\n'
  
      string += '+-' + '-+-'.join(dividers) + '-+' + '\n'
      string += '| ' + ' | '.join(paddedLabels) + ' |' + '\n'
      string += '+=' + '=+='.join(dblDividers) + '=+' + '\n'
      string += paddedString
      string += '+-' + '-+-'.join(dividers) + '-+' + '\n'
  </code></pre>
  
  <p>And this is the result.</p>
  
  <pre>
  
  +----+---------+-----------+------------+----------+-----------+--------------+
  | id | Version | chip_name |  xversion  |  device  | opt_param | place_effort |
  +====+=========+===========+============+==========+===========+==============+
  | 1  |   1.0   |  virtex2  | xilinx11.5 | xc5vlx50 |   Speed   |     High     |
  | 2  |   1.0   |  virtex2  | xilinx11.5 | xc5vlx50 |   Speed   |     High     |
  +----+---------+-----------+------------+----------+-----------+--------------+
  </pre>
  
  <p>Thanks for the help.</p>