title: Catch specific exceptions with try...except
body: <p>I have some code to rename a whole bunch of files and move them to a new directory using <code>os.rename()</code>.  Its fairly simple, nothing flashy.  It worked until I had some overlap in batches and there were duplicate files, this raised a <code>WindowsError</code>.  Since the code worked in all otherways, I did</p>
  
  <pre><code>try:
      os.rename(...)
  except WindowsError:
      print "Duplicate file {}".format(fileName)
  </code></pre>
  
  <p>This worked fine, except that it implies that all <code>WindowsError</code>s are from duplicate files.  The result was that when another aspect of my script broke, it failed essentially silently.  </p>
  
  <p>How can I employ <code>try...except</code> to catch only specific exceptions? If its not possible, what workarounds exist?</p>