星期四, 6月 24, 2010

[Python] Debugging Python by PDB


最近寫Python寫到快瘋了..... 被Visual Studio寵壞的我

其實十分不習慣Eclipse....用vi也是不是很順

Debugging更痛苦........ 所以下定決定好好研究一下python debugging 的技巧.........

以下這一篇大概是比較step by step很好簡易的介紹...

the Python debugger � Python Conquers The Universe

[Summary]

1.

在code任何地方 可以下中斷點 by inserting the line below
pdb.set_trace # 但記得要import pdb

2. 然後就可以直接執行程式了 python your_program.py

3. 就會進入 (Pdb) 這時候就可以開始用console來debugging了

重點的指令如下

n : next statement

[ENTER] : repeat last debugging command

q: quit the debugging

p : print..... (example: p a,b,c)

c : continue

l : list the current line of program

s : step into subroutines

r : return the current subroutines

![command python scripts] : execute some python scripts (example: !b = 'BBB')









沒有留言: