Pythonスクリプトを走らせたときに,エラーになったらデバッガに入ってほしいときに使うと便利な関数メモ
pdbよりも強いIpyhoon.coreのdebuggerを使う方法です.
set_debugger.py
import sys
def set_debugger_org():
if not sys.excepthook == sys.__excepthook__:
from IPython.core import ultratb
sys.excepthook = ultratb.FormattedTB(call_pdb=True)
def set_debugger_org_frc():
from IPython.core import ultratb
sys.excepthook = ultratb.FormattedTB(call_pdb=True)
def set_trace():
from IPython.core.debugger import Pdb
Pdb(color_scheme='Linux').set_trace(sys._getframe().f_back)
としてset_debugger_org_frc()
などをmain関数内で呼んであげれば良い.
うまくデバッガに入ってくれないときも残念ながらあります.
こちら先輩に教わりました.ありがとうございます.
Author And Source
この問題について(Pythonスクリプトを走らせたときに,エラーになったらデバッガに入ってほしいときに使うと便利な関数メモ), 我々は、より多くの情報をここで見つけました https://qiita.com/LittleWat/items/79741b26a080c2dfb2f7著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .