简体   繁体   English

使用简单的命令行在 VS 代码中调试 Python(如: debug(function) )

[英]Debugging Python in VS code with simple command line (like: debug(function) )

I am used to debugging in RStudio.我习惯在RStudio中调试。 Using R I simply use the command: debug(my_function), then run the code and automatically the script debugs at my_function.使用 R 我只需使用命令:debug(my_function),然后运行代码并在 my_function 处自动调试脚本。

Now I am using Python in VS Code, I see debugging is possible by setting breakpoints visually using the red dots.现在我在 VS Code 中使用 Python,我发现可以通过使用红点直观地设置断点来进行调试。 However I need to debug a function without actually knowing where this function is stated.但是,我需要调试 function 而实际上不知道该 function 的说明位置。 So my question is can I debug a specific function in VS Code using a command?所以我的问题是我可以使用命令在 VS Code 中调试特定的 function 吗?

I hope to use something like this command line -> debug(my_function)我希望使用类似这样的命令行 -> debug(my_function)

Thanks!谢谢!

It looks impossible for now, I have submitted a feature request on GitHub.现在看起来不可能,我已经在 GitHub 上提交了功能请求

Maybe you can try to copy the function into an isolated python file to debug it for now.也许您可以尝试将 function 复制到一个隔离的 python 文件中以暂时对其进行调试。

They are called Function Breakpoints它们被称为Function 断点

A function breakpoint is created by pressing the + button in the BREAKPOINTS section header and entering the function name.通过按下 BREAKPOINTS 部分 header 中的 + 按钮并输入 function 名称来创建 function 断点。 Function breakpoints are shown with a red triangle in the BREAKPOINTS section. Function 断点在 BREAKPOINTS 部分显示为红色三角形。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM