-
Book Overview & Buying
-
Table Of Contents
Palo Alto Networks from Policy to Code
By :
As you make changes to the code, you may naturally introduce software errors. While the IDE usually catches syntax mistakes very quickly (literally as you type), algorithmic, logical, and API errors aren’t that easy to see.
When a Python program fails, it produces a so-called traceback referencing the module where the error occurred. Here is an example of the default traceback output:

Figure 9.7 – Regular Python traceback
I am sure you will agree it does not look pretty.
In this artificial example, it is quite obvious that the variable d is somehow assigned a 0, leading to the classic division by zero error. However, it may not be as clear when encountering a more complex error. You may want to see the runtime values of all variables and gain more context for the error. This is where the Rich module proves to be very handy.
We enable the traceback globally as follows:
if settings.RICH_TRACEBACKS:
from rich...