所以我在调试一段巨大的代码,这是一项巨大的任务。代码包含许多条件(if/else)语句,为了使调试工作更容易,我想看看解释器通过所有if/else的“路径”。你知道吗
例如:
if stuff:
x = "stuff"
elif otherstuff:
x = "otherstuff"
else:
x = "evenmorestuff"
return x
我的实际代码要复杂得多,用return
代替x
不是一个选择。但我希望你能明白。你知道吗
我想看看当我的代码崩溃时,通过ifs、elifs和elses的“路径”是什么。例如:
| if stuff:
> x = "stuff" (ran this line)
| if morestuff:
| y = "morestuff" (skipped this line)
| else:
> y = "nostuff" (ran this line)
|elif otherstuff:
| x = "otherstuff" (skipped this line)
|else:
| x = "evenmorestuff" (skipped this line)
>return x (ran this line)
在任何IDE中,有什么特性可以做到这一点吗?(我正在使用带有PTVS和Python的visualstudio Community 2015,所以如果有解决方案的话,那就太好了,因为我不必切换ide。)我只是不知道它叫什么,当我搜索类似于这个标题的内容时,google搜索没有结果,所以我决定在这里询问。你知道吗
谢谢:)
你要找的动词是“追踪”。你知道吗
Python有一个
trace
模块可以做到这一点。我在网上找到文章 tracing in general和the module itself看起来很有用。你知道吗您可能会发现,将代码重构为更小的函数可以更容易理解和/或跟踪其执行情况。你知道吗
相关问题 更多 >
编程相关推荐