Explode out of your function
Debugging with Jupyter
This had been bugging me for a long while. Jupyter (or IPython) has decent
support for debugging via the magic command %debug
.
However, it does not quite cut it for me. The problems with it are well known:
- Cannot run code elsewhere without quitting
pdb
first. - Refreshing the notebook would leave you with a non-responsive kernel.
gdb
like syntax, which can be conflict with variable names and introduces surprises.- Tab completion doesn’t work.
- Command recall (using arrow keys) doesn’t work reliably, etc.
Bring out the local variables
One of the most useful features of %debug
is that it allows me to inspect the
current values of the local variables in each frame and I believe that information
itself would be sufficient for me to debug my problems.
Force out the local variables
Hence, I wrote a quick Python function which will allow me to explode out of my functions and will spill all the local variables in my global namespace:
To use it, consider the following:
If this helps me out with my debugging as much as I think it will, I will release it as a simple Python package with some more bells and whistles.