[英]Is it possible to run commands in IPython with debugging?
Here are my actions in IPython: 以下是我在IPython中的行为:
> import my_module
> import ipdb
Now, my module lacks any executable code, it only declares classes. 现在,我的模块缺少任何可执行代码,它只声明类。 So I want to make a statement:
所以我想发表一个声明:
> g = my_module.Graph()
> f = open('test.osm')
> g.from_osm(f)
I want to put a breakpoint inside Graph.from_osm, without editing the file. 我想在Graph.from_osm中放置一个断点,而不编辑文件。 I don't want to put the latter lines into the file and to do
python -m ipdb ...
. 我不想把后面的行放到文件中并做
python -m ipdb ...
I just want to run commands and debug. 我只想运行命令和调试。
Is this possible? 这可能吗?
added: I see, it's possible to 补充:我明白了,有可能
%run -d script_name
or 要么
> import pdb
> pdb.run('statement')
but it's impossible to do ipdb.run('statement')
, there's no .run
in ipdb
! 但是不可能做
ipdb.run('statement')
, ipdb
没有.run
!
Since IPython 3.2.2
, the %debug
magic, if given an argument (a single line or a cell), executes it under debugger. 从
IPython 3.2.2
, %debug
magic,如果给出一个参数(单行或单元格),则在调试器下执行它。
--breakpoint
argument that sets one more breakpoint (as a part of the command, it'll be saved in command history, saving you the typing for repeated invocations). --breakpoint
参数(作为命令的一部分,它将保存在命令历史记录中,为您节省重复调用的输入)。 也许IPython中的'magic'命令%debug和/或%pdb可以帮助你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.