我可以进入Python库代码吗? [英] Can I step into Python library code?
问题描述
运行Python调试器时,我可以进入编写的函数。但是,例如,如果我尝试进入诸如 os.mkdir( folder)
之类的库函数,它将代替它。
When I run my Python debugger, I can step into functions that I write. But if I try to step into a library function like os.mkdir("folder")
, for example, it "steps over" it instead. Is there a way to step into builtin library functions to see what Python is doing under the hood?
理想情况下,有一种方法可以在PyPy中执行此操作,以便您了解Python在幕后的工作方式。可以继续深入研究Python代码。
Ideally there'd be a way to do this in PyPy so that you could keep drilling down into Python code.
推荐答案
pdb
,Python调试器无法进入 os.mkdir
这样的C函数,但是 gdb
可以。试试这个:
pdb
, the Python Debugger, cannot step into C functions like os.mkdir
, but gdb
can. Try this:
gdb --args python whatever.py ...
然后:
start
break posix_mkdir
continue
您应该看到它停止在python的os.mkdir实现中,如此处所述: https://stackoverflow.com/a/16617835/4323
You should see it stop inside Python's implementation of os.mkdir, as detailed here: https://stackoverflow.com/a/16617835/4323
这篇关于我可以进入Python库代码吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!