Can I trace all the functions/methods executing in a python script?

妖精的绣舞 提交于 2019-11-28 00:06:44

问题


Is there a way to programmatically trace the execution of all python functions/methods? I would like to see what arguments each of them was called with. I really mean all, I'm not interested in a trace decorator.

In Ruby, I could alias the method I wanted and add the extra behaviour there.


回答1:


Have a look at the trace module.

You can also use it via the command line:

python -m trace --help


来源:https://stackoverflow.com/questions/1005665/can-i-trace-all-the-functions-methods-executing-in-a-python-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!