title: prevent the closure of command Prompt with Python when an "exception" occurs
body: <p>I have a script in Python 2.7 converted in executable with py2exe. The INPUT data is a text file where the delimiter need to be valid following this function:</p>
  
  <pre><code># Check if delimeter is valid
  def get_parse(filename, delimiters=['\t', ',', ' ', ':', ';', '-']):
      with open(filename) as f:
          f.next()
          secondline = f.next()
      for delimiter in delimiters:
          if len(secondline.rstrip().split(delimiter)) &gt;= 3:
              return delimiter
      raise Exception("couldn't find a delimiter that worked!")
  </code></pre>
  
  <p>When the delimiter is not valid (ex: a dot) i am looking for two solution in a Python elegant way:</p>
  
  <ul>
  <li>Until the right INPUT data is not load you can not pass to OUTFILE</li>
  </ul>
  
  <p>or</p>
  
  <ul>
  <li>The script break the code, show the error, but the windows (when is a
  *.exe) doesn't close immediately leaving the user without an explanation</li>
  </ul>
  
  <hr>
  
  <pre><code>INPUT = raw_input("Input (*.txt): ")
  while not os.path.exists(INPUT):
        print IOError("No such file or directory: %s" % INPUT)
        INPUT = raw_input("Input (*.txt): ")
  try:
      parse = get_parse(INPUT)
  except Exception:
      print ValueError("Delimiter type not valid")
      break
  OUTPUT = raw_input("Output (*.txt): ")
  </code></pre>
  
  <p>with this solution (break) the Window of my *.exe file close leaving the user without an explanation</p>