在 PyCharm 中调试时如何避免进入内置函数?

How to avoid step into built-in functions when debugging in PyCharm?(在 PyCharm 中调试时如何避免进入内置函数?)

本文介绍了在 PyCharm 中调试时如何避免进入内置函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如:

df = load_dataset(os.path.join(os.path.dirname(dataset), "aclImdb"))

我不想调试 dirnamejoin,因为它们是 Python 内置函数,但只想调试用户定义的函数,如 load_dataset.

有没有办法在 PyCharm 中控制它?

解决方案

当你按下

以下是仅使用标准库的代码示例,可复制用于测试

导入操作系统定义我的函数():返回 2my_str = str(os.path.join(os.getcwd(), str(my_function())))

此屏幕截图显示使用 Step into F7 未选中 Do not step into library scriptsAlways do smart step into已检查.

注意 3 个设置选项是相互关联的,如果您选择 Do not step into library scriptsAlways do smart step into IDE 仍然会给您一个选择进入库函数.如果您取消选中后一个选项,上述示例将自动进入您的函数.

For example:

df = load_dataset(os.path.join(os.path.dirname(dataset), "aclImdb"))

I don't want to debug dirname and join, since they are Python built-in functions, but only want to debug user defined functions like load_dataset.

Is there a way to control that in PyCharm?

解决方案

It's possible to stop the debugger from stepping into library functions when you press Step into F7 bu going to File > Settings > Build, Execution, Deployment > Debugger > Stepping > Python and checking the option Do not step into library scripts.

(One alternative could also be using Step into my code Alt + Shift + F7).

As shown in the screenshot.

The following is a code example using only standard library that can be copied for testing

import os


def my_function():
    return 2


my_str = str(os.path.join(os.getcwd(), str(my_function())))

This screenshot shows using Step into F7 having Do not step into library scripts unchecked and Always do smart step into checked.

Notice the 3 setting options are interconnected, if you choose Do not step into library scripts together with Always do smart step into the IDE will still give you a choice to step into the library function. If you uncheck the later option the above example will automatically step into your function.

这篇关于在 PyCharm 中调试时如何避免进入内置函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:在 PyCharm 中调试时如何避免进入内置函数?

基础教程推荐