IPython - 在导入的文件中设置断点

时间:2013-01-13 16:01:56

标签: python breakpoints ipython pdb

可以在IPython + pdb中设置断点,如下所示:

run -d -b 150 file1.py 

这会破坏第150行file1.py的执行。 现在,如何在file1.py调用的文件中设置断点?如下所示:

run -d -b file2.py:106 file1.py

导入file2.py并在file1.py内调用。

非常感谢。

1 个答案:

答案 0 :(得分:5)

您可能觉得可行的一个选项是将file1.py变为IPython脚本,即将名称更改为file1.ipy,然后代替

import file2

DO

%run -d -b 106 file2.py

我意识到这可能不太理想,因为它需要编辑file1.py

编辑:这确实是%run命令中的有用功能。我已将其添加到此处:https://github.com/ellbur/ipython

此外,如果你有使用pdb的解决方案,你也可以将其作为答案发布。