2

i want to interactively debug code that is deeply hidden in some class.

I know that it is possible open the ipdb using

from IPython.core.debugger import Pdb
Pdb().set_trace()

This work also in ipython (jupyter) notebook.

Another possibility that I find very convenient when I am working in the terminal is to open a shell at a specific point using

from IPython import embed
embed()

and then use ipython directly to interact with variables etc. However, if I use this in notebook, I get a ipython shell embedded into the notebook, and this shell does not even work well (e.g., if I use print, the kernel blocks).

What I would find most convenient is to interrupt the kernel execution at some predefined point in the code and keep all current variables, so that I can use another cell for debugging and the possibility to, e.g., develop and test new code with the current variables. Is there some way to achieve this?

Apoptose
  • 569
  • 1
  • 5
  • 10

0 Answers0