我在同一目录中有以下两个python文件:
main.py
from module import f1
f1()
module.py
import traceback
def f1():
print('f1')
print(traceback.extract_stack()[-1].filename)
print(traceback.extract_stack()[-2].filename)
f2()
def f2():
print('f2')
print(traceback.extract_stack()[-1].filename)
print(traceback.extract_stack()[-2].filename)
我在目录中启动VSCode并使用以下表达式设置条件断点:
traceback.extract_stack()[-2].filename != traceback.extract_stack()[-1].filename
第一print
中陈述f1
和f2
。
运行main.py打印出来:
f1
c:\Users\...\tmp\pythonTest-breakpoint\module.py
c:\Users\...\tmp\pythonTest-breakpoint\main.py
f2
c:\Users\...\tmp\pythonTest-breakpoint\module.py
c:\Users\...\tmp\pythonTest-breakpoint\module.py
两个断点均被触发。
为什么在不满足条件的情况下触发f2中的断点?
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句