On Sun, 25 Jun 2017 05:50 pm, Paul Rubin wrote: > Steve D'Aprano <steve+pyt...@pearwood.info> writes: >> What's the right/best way to test whether an object is an exception >> ahead of time? (That is, without trying to raise from it.) > > Maybe I'm missing something but > isinstance(obj, Exception) > seems to work.
Not well enough I'm afraid: py> isinstance(KeyboardInterrupt(), Exception) False py> isinstance(ValueError, Exception) False -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list