以下を使用して、Python スクリプトのエラーを検査するのが好きです。
$ python3 -m pdb my_script.py
c
これにより、実行を続行できる pdb プロンプトが表示されます。エラーが発生した場合は、変数を調べq
てスクリプトの実行を終了し、シェルに戻ることができます。
よりカラフルなので、iPythonデバッガーモジュールで同じことを試しました:
$ python3 -m ipdb my_script.py
ただし、エラーの調査が完了すると、デバッガーを終了できません。quit コマンドを使用q
すると、スクリプトの再実行と事後分析モードを切り替えるだけです。
$ python3 -m ipdb my_script.py
ipdb> c
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
ipdb> Inspect some variables at this point
ipdb> q
Post mortem debugger finished. The my_script.py will be restarted
ipdb> q
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
ipdb> q
Post mortem debugger finished. The my_script.py will be restarted
ipdb> q
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
ipdb> q
Post mortem debugger finished. The my_script.py will be restarted
ipdb> q
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
このデバッガを終了するには?