code: def CleanComments(line, quote=False):
      
      if line.find('#') == -1 and line.find('"') == -1:
          if quote:
              return '', quote
          else:
              return line, quote
      # else have to check for comment
      prior = []
      prev = ''
      for char in line:
          try:
              if char == '"':
                  if prev != '\\':
                      quote = not quote
                      prior.append(char)
                  continue
              elif char == '#' and not quote:
                  break
              if not quote:
                  prior.append(char)
          finally:
              prev = char
  
      # rstrip removes trailing space between end of command and the comment # start
  
      return ''.join(prior).rstrip(), quote
docs: quote means 'was in a quote starting this line' so that
      quoted lines can be eaten/removed.