Debugging with pycharm, how to step into project, without entering django libraries(用pycharm调试,如何步入项目,无需进入django库)
问题描述
想想这个场景:
我调试我的 Django 项目并逐步执行代码(进出).调试器有时会进入 Django 库或其他外部库.
I debug my Django project and I step through the code (in and out). The debugger sometimes enters Django libraries or other external libraries.
有谁知道如何防止调试器输入外部代码?或者至少是大"一步让调试器回到项目代码?
Does anyone know how to prevent the debugger from entering external code? Or at least a 'big' step out to get the debugger back to the project code?
推荐答案
有谁知道如何防止调试器输入外部代码?
Does anyone know how to prevent the debugger from entering external code?
是的,Dmitry Trofimov 知道;
Yes, Dmitry Trofimov knows;
(...) 在 <pycharm-distr>/helpers/pydev/pydevd.py
中将不想跟踪的模块添加到字典 DONT_TRACE
这是一个 hacky 解决方案 (...)
(...) add modules you don't want to trace to the dict
DONT_TRACE
in<pycharm-distr>/helpers/pydev/pydevd.py
That is a hacky solution (...)
如果您希望此功能不那么 hacky,您可以通过访问 issue 对其进行投票
PY-9101 为 Python 调试器实现不要步入类"选项
If you want this feature to be less hacky you can vote on it by visiting issue
PY-9101 Implement "Do not step into the classes" option for Python debugger
使用 pdb 的人可能有兴趣知道 pdb 中有这样的功能;
Those using pdb might be interested to know there is such a feature in pdb;
从 Python 3.1 开始,Pdb
类有一个名为 跳过
-
Starting with Python 3.1, Pdb
class has a new argument called skip
-
class pdb.Pdb(completekey='tab', stdin=None, stdout=None, skip=None, nosigint=False)
skip 参数,如果给定,必须是一个可迭代的 glob 样式模块名称模式.调试器不会进入源自的帧在与这些模式之一匹配的模块中.1
The skip argument, if given, must be an iterable of glob-style module name patterns. The debugger will not step into frames that originate in a module that matches one of these patterns. 1
1 是否认为帧来自在某个模块中是由框架全局变量中的 __name__
确定.
1 Whether a frame is considered to originate in a certain module is
determined by the __name__
in the frame globals.
文档中给出的示例显示了如何跳过 Django 的包 -
The example given in the docs shows how to skip Django's packages -
导入pdb;pdb.Pdb(skip=['django.*']).set_trace()
这篇关于用pycharm调试,如何步入项目,无需进入django库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:用pycharm调试,如何步入项目,无需进入django库


基础教程推荐
- Dask.array.套用_沿_轴:由于额外的元素([1]),使用dask.array的每一行作为另一个函数的输入失败 2022-01-01
- 如何让 python 脚本监听来自另一个脚本的输入 2022-01-01
- 筛选NumPy数组 2022-01-01
- 使用PyInstaller后在Windows中打开可执行文件时出错 2022-01-01
- Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll 2022-01-01
- 在 Python 中,如果我在一个“with"中返回.块,文件还会关闭吗? 2022-01-01
- 用于分类数据的跳跃记号标签 2022-01-01
- 何时使用 os.name、sys.platform 或 platform.system? 2022-01-01
- 线程时出现 msgbox 错误,GUI 块 2022-01-01
- 如何在海运重新绘制中自定义标题和y标签 2022-01-01