title: python - specifically handle file exists exception
body: <p>I have come across examples in this forum where a specific error around files and directories is handled by testing the <code>errno</code> value in <code>OSError</code> (or <code>IOError</code> these days ?). For example, some discussion here - <a href="https://stackoverflow.com/questions/15032108/pythons-open-throws-different-errors-for-file-not-found-how-to-handle-b">Python&#39;s &quot;open()&quot; throws different errors for &quot;file not found&quot; - how to handle both exceptions?</a>. But, I think, that is not the right way. After all, a <code>FileExistsError</code> exists specifically to avoid having to worry about <code>errno</code>.</p>
  
  <p>The following attempt didn't work as I get an error for the token <code>FileExistsError</code>.</p>
  
  <pre><code>try:
      os.mkdir(folderPath)
  except FileExistsError:
      print 'Directory not created.'
  </code></pre>
  
  <p>How do you check for this and similar other errors specifically ?</p>