How can I more easily suppress previous exceptions when I raise my own exception in response?

In Python 3.3 and later raise ... from None may be used in this situation.

try:
   import someProprietaryModule
except ImportError:
   raise ImportError('It appears that <someProprietaryModule> is not installed...') from None

This has the desired results.

Leave a Comment