有没有办法让 pdb 和 Mac Terminal 很好地发挥作用?
调试 django 应用程序时,我使用 pdb 通过 pdb.set_trace()
进行交互式调试。
但是,当我修改文件时,本地 django Web 服务器会重新启动,然后我看不到我在终端中输入的内容,直到我输入 reset
。
无论如何,这是否会自动发生?这可能真的很烦人,必须取消运行服务器并一直重置并重新启动它。有人告诉我这不会发生在其他操作系统(ubuntu)上,所以有什么办法可以让它不会发生在 Mac 上吗? (我正在使用雪豹)。
When debugging my django apps I use pdb for interactive debugging with pdb.set_trace()
.
However, when I amend a file the local django webserver restarts and then I cant see what I type in the terminal, until I type reset
.
Is there anyway for this to happen automatically? It can be real annoying, having to cancel the runserver and reset and restart it all the time. I'm told it doesn't happen on other OS's (ubuntu) so is there anyway to make it not happen on the Mac? (I'm using Snow Leopard).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好的 - 这对我有用我创建了一个 ~/.pdbrc 并添加
现在,每次运行 pdb 时,它都会将线路设置恢复为 sane。
如果我掉到终端,那么我仍然必须手动执行此操作 - 但它解决了必须退出 runserver 并始终重置的问题。
OK - this works for me I created a ~/.pdbrc and added
Now each time pdb is run it sets the line settings back to sane.
If I fall out to the terminal then I still have to do it manually - but it solves having to quit runserver and reset all the time.
在保存对文件的更改之前,尝试 [
q
]uit pdb。这将防止控制台对您产生影响,但仅限于 pdb.set_trace() 的一次运行。当您忘记退出 pdb 时,您仍然必须回退到旧的 ^C +
reset
+./manage.py runserver
。可以让重置不那么烦人的一件事是将重置和运行服务器放在一行上。这样,只需快速^Rreset
或向上箭头即可重置。Try to [
q
]uit pdb before you save changes to a file. This will keep the console from wigging out on you but only for that one run of pdb.set_trace().You will still have to fallback to the old ^C +
reset
+./manage.py runserver
when you forget to quit pdb. One thing that can make the reset a little less annoying is to put the reset and runserver onto one line. That way the reset is just a quick^Rreset
or up-arrow away.我发现最好的方法是在 pdb 内进行重置,如下所示:
The best I've found is doing a reset inside pdb like so: