title: Handling Python IOError
body: <p>My program writes to a file using python. All goes well unless I already ran the file and kept the file open, throwing an IOError: [Errno 13] Permission denied: 'pathname'.</p>
  
  <p>I'm wondering the best way to exit from the program and launch a message box to explain the issue to the user, instructing to close the previous file for overwrite.</p>
  
  <pre><code>def myFunction(self):
      with open(self.pathString, 'wb') as ofile:
      writer = csv.writer(ofile, quoting=csv.QUOTE_NONE, delimiter='\t')
      ...
      if IOError:
          QMessageBox.information(None, 'Information', 'A message')
          return
  </code></pre>