使用PDB调试应用程序

pdb is an interactive tool that comes with Python, which allows you to break your program at an arbitrary point, examine values, and step through code. It's often much more useful than print statements or logging statements to examine program state. 你可以放置一个 pdb.set_trace() 在 Pyramid 应用程序中的一个要检查程序状态的位置。当您向应用程序发出请求,并且到达代码中的该点时,您将被放入 pdb 在用于启动应用程序的终端中调试控制台。

有很多很好的资源可以帮助你学习PDB。

  • DougHellmann的pymotw博客条目名为“pdb-交互式调试器”,网址为https://pymotw.com/3/pdb/,是学习pdb的规范文本资源。

  • Chris McDonough在https://pyvideo.org/video/644/introduction-to-pdb上题为“PDB简介”的Pycon视频演示是学习PDB的好地方。

  • 位于https://pyvideo.org/pycon-us-2012/introduction-to-pdb.html的视频向您展示了如何开始使用pdb。视频描述了使用 pdb 在命令行程序中。