I'm trying to catch two exceptions as follows:
class TestException:
def __init__(self):
self.x = [1, 2, 3]
def main():
test_exception = TestException()
try:
test_exception.y[1] = 4.0
except (IndexError, AttributeError) as e:
raise e('Why does this not work?')
if __name__ == '__main__':
main()
but I get the following error:
TypeError: 'AttributeError' object is not callable
Why does this occur? Because the following works fines:
raise AttributeError('This does work!')
Thanks for any help.