title: Handle specific exception type in python
body: <p>I have some code that handles an exception, and I want to do something specific only if it's a specific exception, and only in debug mode. So for example:</p>
  
  <pre><code>try:
      stuff()
  except Exception as e:
      if _debug and e is KeyboardInterrupt:
          sys.exit()
      logging.exception("Normal handling")
  </code></pre>
  
  <p>As such, I don't want to just add a:</p>
  
  <pre><code>except KeyboardInterrupt:
      sys.exit()
  </code></pre>
  
  <p>because I'm trying to keep the difference in this debug code minimal</p>