'n' 在 pdb 中让我进入 pdb.set_trace() 方法
'n' in pdb moves me inside of the pdb.set_trace() method
我正在尝试使用 this tutorial referenced from another Whosebug question 学习 pdb,我正处于“入门”部分的第 3 步。
In [12]: %paste
# epdb1.py -- experiment with the Python debugger, pdb
import pdb
a = "aaa"
pdb.set_trace()
b = "bbb"
c = "ccc"
final = a + b + c
print final
## -- End pasted text --
--Return--
> <ipython-input-12-48afa1c7ad72>(4)<module>()->None
-> pdb.set_trace()
(Pdb) l
1 # epdb1.py -- experiment with the Python debugger, pdb
2 import pdb
3 a = "aaa"
4 -> pdb.set_trace()
5 b = "bbb"
6 c = "ccc"
7 final = a + b + c
8 print final
[EOF]
(Pdb) n
> /Users/jg/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.py(3038)run_code()
-> sys.excepthook = old_excepthook
(Pdb) l
3033 self.hooks.pre_run_code_hook()
3034 #rprint('Running code', repr(code_obj)) # dbg
3035 exec(code_obj, self.user_global_ns, self.user_ns)
3036 finally:
3037 # Reset our crash handler in place
3038 -> sys.excepthook = old_excepthook
3039 except SystemExit as e:
3040 if result is not None:
3041 result.error_in_exec = e
3042 self.showtraceback(exception_only=True)
3043 warn("To exit: use 'exit', 'quit', or Ctrl-D.", level=1)
看起来 n(ext) 应该将我移动到当前帧的下一行:
(Pdb) help next
n(ext)
Continue execution until the next line in the current function
is reached or it returns.
并且在教程的示例中似乎成功地做到了这一点。但在我的 ipython 中,它似乎将我移动到 pdb.set_trace() 代码中的下一行。
如何简单地导航到 'b = "bbb"' 行?
在您的 ipython 中试试这个:
import pdb
def test_pdb_example():
a = "aaa"
pdb.set_trace() # use 'n' for navigate to next line
b = "bbb"
c = "ccc"
final = a + b + c
return final
test_pdb_example()
我正在尝试使用 this tutorial referenced from another Whosebug question 学习 pdb,我正处于“入门”部分的第 3 步。
In [12]: %paste
# epdb1.py -- experiment with the Python debugger, pdb
import pdb
a = "aaa"
pdb.set_trace()
b = "bbb"
c = "ccc"
final = a + b + c
print final
## -- End pasted text --
--Return--
> <ipython-input-12-48afa1c7ad72>(4)<module>()->None
-> pdb.set_trace()
(Pdb) l
1 # epdb1.py -- experiment with the Python debugger, pdb
2 import pdb
3 a = "aaa"
4 -> pdb.set_trace()
5 b = "bbb"
6 c = "ccc"
7 final = a + b + c
8 print final
[EOF]
(Pdb) n
> /Users/jg/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.py(3038)run_code()
-> sys.excepthook = old_excepthook
(Pdb) l
3033 self.hooks.pre_run_code_hook()
3034 #rprint('Running code', repr(code_obj)) # dbg
3035 exec(code_obj, self.user_global_ns, self.user_ns)
3036 finally:
3037 # Reset our crash handler in place
3038 -> sys.excepthook = old_excepthook
3039 except SystemExit as e:
3040 if result is not None:
3041 result.error_in_exec = e
3042 self.showtraceback(exception_only=True)
3043 warn("To exit: use 'exit', 'quit', or Ctrl-D.", level=1)
看起来 n(ext) 应该将我移动到当前帧的下一行:
(Pdb) help next
n(ext)
Continue execution until the next line in the current function
is reached or it returns.
并且在教程的示例中似乎成功地做到了这一点。但在我的 ipython 中,它似乎将我移动到 pdb.set_trace() 代码中的下一行。
如何简单地导航到 'b = "bbb"' 行?
在您的 ipython 中试试这个:
import pdb
def test_pdb_example():
a = "aaa"
pdb.set_trace() # use 'n' for navigate to next line
b = "bbb"
c = "ccc"
final = a + b + c
return final
test_pdb_example()