So I import a module: from IPython.core.debugger import Pdb Then I initiate an object for debugging: ipdb = Pdb() I define a function to test debug mode: def f(a=1): ipdb.set_trace() print(a) After I run the function: f() I am in the debug mode, but if someone clear the output or switch the mode of the cell from code to markdown or NBconvert, then I lose the control of the debug mode,and to make things worse the interrupt key will not work any more(which is a very helpful weapon if you run a cell never ending), is there a way to get back the control of the debugger or at least quit the debugger mode instead of kill the whole kernel? Continue reading...