如何使用idle3处理多个源文件调试?

时间:2018-02-06 07:55:42

标签: python python-3.x python-idle

我知道如何调试单个文件,但到目前为止,导入文件上的断点不起作用。

test1.py

import test2

print(do_stuff)

test2.py

def do_stuff():
   str = "hello world" # <- set breakpoint here
   return str

在test2.py中设置断点并在idle3中运行test1.py时,程序不会停止。如何处理多个源文件调试?

1 个答案:

答案 0 :(得分:3)

你的代码是错误的,因为它永远不会运行带有断点的行,该断点位于未调用的函数内。我刚刚在Windows上测试了3.5.4和3.7.0b1,导入文件中的断点工作正常。

# a/tem.py (in path)
a = 3
b = 4  # breakpoint
def c():
    d = 5  # breakpoint
    return 'c ran'

# a/tem2.py
from a.tem import c
print(c)
print(c())

# prints
<function c at 0x0000023921979840>
c ran

在不同的IDE中运行错误代码不会让它神奇地运行。