There’s a raise_from in python-future; simply install it
pip install future
and import to use
from future.utils import raise_from
# or: from six import reraise as raise_from
class FileDatabase:
def __init__(self, filename):
try:
self.file = open(filename)
except IOError as exc:
raise_from(DatabaseError('failed to open'), exc)
UPDATE
The compatibility package six also supports raise_from, from version 1.9 (released in 2015). It is used in the same manner as above.