我目前正在使用NetBeans IDE和Jython 2.5.1Python調試器是否在發生器中步進?
當一步步調試我的項目時,只要遇到對生成器的迭代,調試器就會直接到代碼的末尾。輸出工作正常,但一旦滿足第一個生成器就不可能一步一步地進行調試。
這是在所有Python IDE中進行Python調試的標準行爲嗎? 是不是可以調試代碼「yield yield之後」,就像我們可以爲「for」循環的每個元素調試VBA一樣(對於提及VBA,抱歉:)?
謝謝。
編輯
沒有產生
代碼:
def example(n):
i = 1
while i <= n:
yield i
i += 1
print "hello"
print "goodbye"
輸出:
hello
goodbye
調試:
[LOG]PythonDebugger : overall Starting
[LOG]PythonDebugger.taskStarted : I am Starting a new Debugging Session ...
[LOG]This window is an interactive debugging context aware Python Shell
[LOG]where you can enter python console commands while debugging
(...)
>>>[stdout:]hello
>>>[stdout:]goodbye
Debug session normal end
與發電機
代碼:
def example(n):
i = 1
while i <= n:
yield i
i += 1
print "hello"
for n in example(3):
print n
print "goodbye"
輸出:
hello
1
2
3
goodbye
調試:
[LOG]PythonDebugger : overall Starting
[LOG]PythonDebugger.taskStarted : I am Starting a new Debugging Session ...
[LOG]This window is an interactive debugging context aware Python Shell
[LOG]where you can enter python console commands while debugging
(...)
>>>[stdout:]hello
>>>None['GeneratorExit
deamon ended
']
Debug session normal end
發佈您的代碼。它會澄清你的問題。 – Blender 2012-01-29 05:28:55