May 2019
Beginner
528 pages
29h 51m
English
Each exception object stores information indicating the precise series of function calls that led to the exception. This is helpful when debugging your code. Consider the following function definitions—function1 calls function2 and function2 raises an Exception:
In [1]: def function1():...: function2()...:In [2]: def function2():...: raise Exception('An exception occurred')...:
Calling function1 results in the following traceback. For emphasis, we placed in bold the parts of the traceback indicating the lines of code that led to the exception:
In [3]: function1()-------------------------------------------------------------------------Exception Traceback (most recent call last)<ipython-input-3-c0b3cafe2087> ...
Read now
Unlock full access