Consider the following code and traceback:
>>> try: ... raise KeyboardInterrupt ... except KeyboardInterrupt: ... raise Exception ... Traceback (most recent call last): File "<stdin>", line 2, in <module> KeyboardInterrupt During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 4, in <module> Exception >>> I'd like to print only the most recent traceback (the one in which Exception was raised).
How can this be achieved?
From the above example, I'd like to print the following, as if raise Exception had been called outside the except clause.
Traceback (most recent call last): File "<stdin>", line 4, in <module> Exception