当通过ipdb.set_trace()调用时,ipython ipdb在调试时不记得命令历史记录 [英] ipython ipdb, when invoked via ipdb.set_trace(), does not remember the command history while debugging

查看:2249
本文介绍了当通过ipdb.set_trace()调用时,ipython ipdb在调试时不记得命令历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我正常运行 ipython ,iPython会记住命令历史记录,例如乱七八糟地在repl中测试基本的东西,但是我希望能够从上一个调试会话中调出调试命令,我正在通过简单地运行我的程序进行调试,其中程序包含

iPython does remember the command history if I run ipython normally, e.g. to mess around testing basic things in the repl, but I would like to be able to pull up the debugging commands from the previous debug session, and I am doing my debugging by simply running my program as normal, where the program contains

import ipdb
def info(type, value, info):
    import traceback
    traceback.print_exception(type, value, info)
    ipdb.pm()

import sys
sys.excepthook = info
trace = ipdb.set_trace

这是设置它所以我可以在任何地方写 trace()在我的程序中,当我运行程序时开始调试,或者当它自己死掉时自动启动事后调试。

Which is to set it up so I can write trace() anywhere in my program to start debugging there when I run the program, or for it to automatically start postmortem debugging when it dies on its own.

在快速代码/测试迭代方面,使用iPython的Python已经超越了其他语言,而我现在已经非常接近于必杀技......

Python with iPython has been leaps and bounds beyond other languages when it comes to quick code/test iterations and I'm just so close to nirvana at this point...

推荐答案

我使用 pudb 代替。它允许从调试器获取真正的ipython shell并保存所有命令

I use pudb instead. It enables getting to a real ipython shell from the debugger and all the commands there are saved

这篇关于当通过ipdb.set_trace()调用时,ipython ipdb在调试时不记得命令历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆