Ash*_*ppa 26 python ipython pdb ipdb
我喜欢使用以下方法检查Python脚本中的错误:
$ python3 -m pdb my_script.py
Run Code Online (Sandbox Code Playgroud)
这让我进入了一个pdb提示符,从那里我可以c继续执行,当它遇到错误时,我可以检查变量然后q退出脚本执行以返回到我的shell.
我尝试使用iPython调试器模块,因为它更加丰富多彩:
$ python3 -m ipdb my_script.py
Run Code Online (Sandbox Code Playgroud)
但是,一旦检查完错误,我就无法退出调试器.使用qquit命令只是在重新执行脚本和事后模式之间保持切换:
$ python3 -m ipdb my_script.py
ipdb> c
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
ipdb> Inspect some variables at this point
ipdb> q
Post mortem debugger finished. The my_script.py will be restarted
ipdb> q
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
ipdb> q
Post mortem debugger finished. The my_script.py will be restarted
ipdb> q
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
ipdb> q
Post mortem debugger finished. The my_script.py will be restarted
ipdb> q
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
Run Code Online (Sandbox Code Playgroud)
如何退出此调试器?
tut*_*uju 31
正如用户@ffeast评论的那样,有一个开放的ipdb问题,并提出了一些解决方法.对我来说这些效果很好:
kill %1