How to import imports when changing from pdb debugger to python command line

时间:2015-10-06 08:54:00

标签: python pdb

When I am debugging a python program using pdb, I enter into python console mode by writing:

(pdb) !import code; code.interact(local=vars())

This is very useful, because it allows you to use python interactively using loops, conditionals and others at the same state as your code is when you broke the execution, and using all the variables at their current state.

The problem is that all the imports have to be imported again, and this can be tiresome when there are many.

Is there a way to have all the imports you had in the python code when changing from debug to command line mode?

1 个答案:

答案 0 :(得分:0)

I just realized that it can be achieved by calling

(pdb) interact