If ones catches an exception outside of the function it is originally thrown, ones loses access to the local stack. As a result one cannot inspect the values of the variables th
For python 3 (today at 3.8), this can be done with
python3 -m pdb myscript.py
From the docs:
When invoked as a script, pdb will automatically enter post-mortem debugging if the program being debugged exits abnormally. After post-mortem debugging (or after normal exit of the program), pdb will restart the program. Automatic restarting preserves pdb’s state (such as breakpoints) and in most cases is more useful than quitting the debugger upon program’s exit.
Note that at launch, python will directly enter pdb mode, and you need to type c
then enter
to start running the script