Debugging from Interactive Window

Sep 26, 2013 at 11:43 AM
Edited Sep 26, 2013 at 11:49 AM
Debugging using the Start button or pressing F5 runs slowly. For this reason sometimes I insert the following statement in the code I want to debug:

Pdb(color_scheme='Linux').set_trace(sys._getframe().f_back)

Then when I run that code either by pressing CTRL+F5 or CTRL+E+E (both run much faster than by pressing F5) execution stops at that line, an ipdb prompt appears and I can start debugging. This works well if I get to that line by clicking on CTRL+F5 or selecting Debug/Start Without Debugging on the menu.

It also works, but not as well, if I get to that line by executing the code from an IPython Interactive Window.

Debugging from the Interactive Window is preferable because I don't have to run all the code from the beginning. I can rewrite the function or method that had a bug, reload its module using

imp.reload(module_name)

and call that function/method in the Interactive Window.

This is good, but there are two problems. First, when debugging in this way the arrow keys do not work to bring back previous commands. Second, one cannot paste in the Interactive Window (only when debugging as described, under normal use of course one can paste). None of these two problems happens if debugging from a CTRL+F5/Start without debugging session. Is there a way to make the arrows work and to paste while debugging in this way?

Thanks for the help.