Fis*_*tor 21 python debugging ipython
当调试Python脚本使用ipdb my_script.py,我想使用魔法的IPython功能,如%paste,%cd在ipdb调试会话外壳.是可能的,怎么样?
Pet*_*ren 18
根据ipdb Github repo魔术IPython功能不可用.幸运的是,IPython调试器提供了一些如何在不启动单独的IPython shell的情况下获得此功能的线索.
这是我做的运行%cpaste:
ipdb> from IPython import get_ipython
ipdb> shell = get_ipython()
ipdb> shell.find_line_magic('cpaste')()
Pasting code; enter '--' alone on the line to stop or use Ctrl-D.
:for i in range(0,5):
: print i
:--
0
1
2
3
4
Run Code Online (Sandbox Code Playgroud)
这样,您可以单步执行代码并通过该方法访问所有IPython魔术函数find_line_magic(your_magic_function).
Luc*_*iro 14
你可以在堆栈中打开一个IPython shell,就像pdb一样.请执行下列操作:
例:
from IPython import embed
def some_func():
i = 0
embed()
return 0
Run Code Online (Sandbox Code Playgroud)
在Python shell中:
>>> te.func()
IPython 1.0.0 -- An enhanced Interactive Python.
(...)
In [1]: %whos
Variable Type Data/Info
i int 0
In [2]:
Run Code Online (Sandbox Code Playgroud)
那是你在寻找什么?
| 归档时间: |
|
| 查看次数: |
3596 次 |
| 最近记录: |