def write_list(data, delims="[]"):
   """Writes a formatted string from a list.

   The format of the output is as for a standard python list, 
   [list[0], list[1],..., list[n]]. Note the space after the commas, and the
   use of square brackets.

   Args:
      data: The value to be read in.
      delims: An optional string of two characters giving the first and last
         character to be printed. Defaults to "[]".

   Returns:
      A formatted string.
   """

   rstr = delims[0]
   
   for v in data:
      rstr += str(v) + ", "
   
   rstr = rstr.rstrip(", ")
   rstr += delims[1]
   return rstr