Format a line of a table.

  Arguments:
    headers: A list of strings that are used as the table headers.
    fields: A list of the same length as `headers` where `fields[i]` is
      the entry for `headers[i]` in this row. Elements can be of
      arbitrary types. Pass `headers` to print the header row.

  Returns:
    A pretty string.

def _format_line(headers, fields):
  """Format a line of a table.

  Arguments:
    headers: A list of strings that are used as the table headers.
    fields: A list of the same length as `headers` where `fields[i]` is
      the entry for `headers[i]` in this row. Elements can be of
      arbitrary types. Pass `headers` to print the header row.

  Returns:
    A pretty string.
  """
  assert len(fields) == len(headers), (fields, headers)
  fields = ["%2.4f" % field if isinstance(field, float) else str(field)
            for field in fields]
  return '  '.join(' ' * max(0, len(header) - len(field)) + field
                   for (header, field) in zip(headers, fields))