code: def rest_table(data, headers):
      
  
      num_cols = len(headers)
      new_data, row_heights = expand_multirow_data(data)
      new_data = [[str(x) for x in row] for row in new_data]
      col_widths = [max([len(x) for x in col]) for col in zip(*new_data)]
      col_widths = [max(cw, len(s)) for cw, s in zip(col_widths, headers)]
  
      if any([x == 0 for x in col_widths]):
          raise RuntimeError("Column widths ({}) has at least one zero".format(col_widths))
  
      num_lines = sum(row_heights) # line != row (rows are multiline)
  
      # horizontal lines
      hl0 = "+"+"+".join(["-"*(n+2) for n in col_widths])+"+"
      hl1 = "+"+"+".join(["="*(n+2) for n in col_widths])+"+"
  
      frmtd = ["{0:{1}}".format(x, width) for x, width in zip(headers, col_widths)]
      ret = [hl0, "| "+" | ".join(frmtd)+" |", hl1]
  
      i0 = 0
      for i, row_height in enumerate(row_heights):
          if i > 0:
              ret.append(hl0)
          for incr in range(row_height):
              frmtd = ["{0:{1}}".format(x, width) for x, width in zip(new_data[i0+incr], col_widths)]
              ret.append("| "+" | ".join(frmtd)+" |")
          i0 += row_height
  
      ret.append(hl0)
      return ret
docs: Creates reStructuredText table (grid format), allowing for multiline cells
  
      Arguments:
        data -- [((cell000, cell001, ...), (cell010, cell011, ...), ...), ...]
        headers -- sequence of strings: (header0, header1, ...)
  
      **Note** Tolerant to non-strings
  
      **Note** Cells may or may not be multiline
  
      >>> rest_table([["Eric", "Idle"], ["Graham", "Chapman"], ["Terry", "Gilliam"]], ["Name", "Surname"])