title: How to extend pretty print module to tables?
body: <p>I have the pretty print module, which I prepared because I was not happy the pprint module produced zillion lines for list of numbers which had one list of list. Here is example use of my module.</p>
  
  <pre><code>    &gt;&gt;&gt; a=range(10)
      &gt;&gt;&gt; a.insert(5,[range(i) for i in range(10)])
      &gt;&gt;&gt; a
      [0, 1, 2, 3, 4, [[], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7, 8]], 5, 6, 7, 8, 9]
      &gt;&gt;&gt; import pretty
      &gt;&gt;&gt; pretty.ppr(a,indent=6)
  
      [0, 1, 2, 3, 4, 
            [
              [], 
              [0], 
              [0, 1], 
              [0, 1, 2], 
              [0, 1, 2, 3], 
              [0, 1, 2, 3, 4], 
              [0, 1, 2, 3, 4, 5], 
              [0, 1, 2, 3, 4, 5, 6], 
              [0, 1, 2, 3, 4, 5, 6, 7], 
              [0, 1, 2, 3, 4, 5, 6, 7, 8]], 5, 6, 7, 8, 9]
  </code></pre>
  
  <p>Code is like this:</p>
  
  <pre><code>""" pretty.py prettyprint module version alpha 0.2
      mypr: pretty string function
      ppr:  print of the pretty string
      ONLY list and tuple prettying implemented!
  """
  def mypr(w, i = 0, indent = 2, nl = '\n') :
      """ w = datastructure, i = indent level, indent = step size for indention """
      startend = {list : '[]', tuple : '()'}
      if type(w) in (list, tuple) :
          start, end = startend[type(w)]
          pr = [mypr(j, i + indent, indent, nl) for j in w]
          return nl + ' ' * i + start + ', '.join(pr) + end
      else :  return repr(w)
  
  def ppr(w, i = 0, indent = 2, nl = '\n') :
      """ see mypr, this is only print of mypr with same parameters """
      print mypr(w, i, indent, nl)
  </code></pre>
  
  <p>Here is one fixed text for table printing in my pretty print module:</p>
  
  <pre><code>## let's do it "manually"
  width = len(str(10+10))
  widthformat = '%'+str(width)+'i'
  for i in range(10):
      for j in range(10):
          print widthformat % (i+j),
      print
  </code></pre>
  
  <p>Have you better alternative for this code to be generalized enough for the pretty printing module?</p>
  
  <p>What I found for this kind of regular cases after posting the question is this module: <a href="http://code.google.com/p/prettytable/" rel="nofollow noreferrer">prettytable A simple Python library for easily displaying tabular data in a visually appealing ASCII table format</a></p>