code: def format_to_example(table, tabspace=2, indent=2):
      
      from io import StringIO
      output = StringIO()
  
      caption, rows = table
  
      # output caption line
      output.write(u'{0}Examples: {1}\n'.format(' ' * indent * tabspace,
                                                caption))
  
      # calculate max length for each column, for aligning
      cols = zip(*rows)
      col_lengths = []
      for col in cols:
          max_length = max([len(format_item(row)) for row in col])
          col_lengths.append(max_length)
  
      # output each row
      for r, row in enumerate(rows):
          output.write(u' ' * (indent + 1) * tabspace)
          output.write(u'|')
          for c in range(len(col_lengths)):
              output.write(u' ')
              output.write(format_item(row[c], r))
              output.write(u' ' * (col_lengths[c] - len(format_item(row[c], r))))
              output.write(u' |')
          output.write(u'\n')
  
      example = output.getvalue()
      output.close()
      return example
docs: format table to *behave* example
      :param table: `(caption, rows)`, each item in `rows` is `(col1, col2,...)`
      :return