(Pdb) p var[TAB] # complete global and local names
var1 var2
(Pdb) [TAB] # complete commands
EOF b cl cont disable exit interact list next quit retval source unalias up
a break clear continue display h j ll p r run step undisplay w
alias bt commands d down help jump longlist pp restart rv tbreak unt whatis
args c condition debug enable ignore l n q return s u until where
4条答案
按热度按时间ttygqcqt1#
iPython是解决这个问题的第三方解决方案。有时候你只能依赖vanilla Python。我找到了两个解决方案。
每shell解决方案-使用模块'rlcompleter':
字符串
系统级解决方案-使用文件~/.pdbrc
型
备注:
1.仅在Python 3.4上测试
1.基于https://reminiscential.wordpress.com/2009/06/12/python-enable-auto-complete-in-a-pdb-session/
omtl5h9j2#
ipdb来救援。
ipdb导出函数以访问IPython调试器,该调试器具有制表符补全、语法突出显示、更好的回溯、更好的内省功能,接口与pdb模块相同。
0ejtzxu13#
官方文件称:
在版本3.3中更改:通过readline模块的制表符完成可用于命令和命令参数,例如当前全局和局部名称作为p命令的参数提供。
https://docs.python.org/3/library/pdb.html
所以你只需要使用
p
命令:字符串
jutyujz04#
如果你使用macOS和NetBSD libedit(默认),或者你的Python不是用GNU readline lib而是用Net BSD libedit编译的,请在
~/.editrc
中插入python:bind ^I rl_complete
。在本例中,^I
有两个字符(^
和I
)。此外,您必须删除您尝试的GNU readline解决方案。例如
~/.pdbrc
(或./.pdbrc
)或rlcompleter
中的某个部分。