title: How to test for an exception object with an `if` statement?
body: <p>How can I test if a function returned an exception object if I don't know in advance what type of exception has been raised?</p>
  
  <pre><code>def func():
      try:
          bad_thing_happens  # NameError("global name 'bad_thing_happens' is not defined",)
          return True
      except Exception as e:
          return e
  
  result = func()
  if result == Exception:
      print 'a bad thing happened'
  </code></pre>
  
  <p>In this case the if statement returns <code>False</code> and I would miss the exception?</p>