bpython3
只是一个交互式 Python shell 的接口。对于类似 gdb 的调试,请使用pdb,它支持类似 gdb 的命令:
$ python3 -m pdb t.py
> /tmp/t.py(2)<module>()
-> def a():
(Pdb) c
Traceback (most recent call last):
File "/usr/lib/python3.2/pdb.py", line 1556, in main
pdb._runscript(mainpyfile)
File "/usr/lib/python3.2/pdb.py", line 1437, in _runscript
self.run(statement)
File "/usr/lib/python3.2/bdb.py", line 405, in run
exec(cmd, globals, locals)
File "<string>", line 1, in <module>
File "/tmp/t.py", line 2, in <module>
def a():
File "/tmp/t.py", line 4, in a
b()
File "/tmp/t.py", line 7, in b
1/0
ZeroDivisionError: division by zero
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> /tmp/t.py(7)b()
-> 1/0
(Pdb) up
> /tmp/t.py(4)a()
-> b()
(Pdb) print x
1
如果你想使用 bpython(3) 作为你的调试器,你必须包含一些胶水代码。