def read_list(data, delims="[]", split=",", strip=" \n\t'"):
   """Reads a formatted string and outputs a list.

   The string must be formatted in the correct way.
   The start character must be delimiters[0], the end character
   must be delimiters[1] and each element must be split along 
   the character split. Characters at the beginning or
   end of each element in strip are ignored. The standard list format is of the
   form '[array[0], array[1],..., array[n]]', which is used for actual lists.
   Other formats are used for tuples and dictionaries.

   Args:
      data: The string to be read in. '[]' by default.
      delims: A string of two characters giving the first and last character of
         the list format. ',' by default.
      split: The character between different elements of the list format.
      strip: Characters to be removed from the beginning and end of each 
         element. ' \n\t' by default.

   Raises: 
      ValueError: Raised if the input data is not of the correct format.

   Returns:
      A list of strings.
   """

   try:
      begin = data.index(delims[0])
      end = data.index(delims[1])
   except ValueError:
      raise ValueError("Error in list syntax: could not locate delimiters")
   
   rlist = data[begin+1:end].split(split)
   for i in range(len(rlist)):
      rlist[i] = rlist[i].strip(strip)

   # handles empty lists correctly
   if len(rlist) == 1 and rlist[0] == "":
      rlist = [] 
    
   return rlist