There is an ipdb
project which embeds iPython into the standard pdb, so you can just do:
import ipdb; ipdb.set_trace()
It's installable via the usual pip install ipdb
.
ipdb
is pretty short, so instead of easy_installing you can also create a file ipdb.py
somewhere on your Python path and paste the following into the file:
import sys
from IPython.Debugger import Pdb
from IPython.Shell import IPShell
from IPython import ipapi
shell = IPShell(argv=[''])
def set_trace():
ip = ipapi.get()
def_colors = ip.options.colors
Pdb(def_colors).set_trace(sys._getframe().f_back)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…