Ben*_*ey4 21 python debugging ipython pdb
我IPython(0.13.1)
和ipdb(0.7)
安装,我插线import ipdb;ipdb.set_trace()
在我的剧本跑python my_script.py
.现在我在ipdb提示符下并且有一些自动完成(例如一个裸标签),但它与我进入IPython时获得的自动完成功能不同.在ipdb提示符中,requests.
然后<tab>
(导入后)没有像IPython那样给我一个属性列表.如何使用ipdb获得与IPython相同的选项卡完成?
顺便说一下,当我运行python -m ipdb my_script.py
选项卡完成时,就像在IPython中一样,但是它的缺点是它从第一行启动调试器而不是我放的行import ipdb;ipdb.set_trace()
.
小智 6
我在Mac上使用ipython==0.13.2
和ipdb==0.7
使用Python 2.7.5
virtualenv时有同样的现象.当我尝试调试时,我有内置函数的选项卡完成,但不适用于当前范围中的变量.我发现,.pdbrc
我的主文件夹中有一个自定义文件(http://docs.python.org/2/library/pdb.html#id2).在我评论了所有的东西后,标签完成再次起作用.
我不知道何时以及为什么我添加了这个文件,但这是在那里:
# See http://docs.python.org/2/library/pdb.html#id2 for the structure of this file.
import pdb
# 'inspect x' will print the source code for a method, class or function.
alias inspect import inspect;print inspect.getsource(%1)
alias i import inspect;print inspect.getsource(%1)
# 'help x' opens the man-style help viewer from the interpretter on an object
alias help !print help(%1)
alias h !print help(%1)
# For ordinary Python objects, ppo will pretty-print members and their values.
alias ppo pp %1.__dict__
# ppio runs ppo over a sequence of objects
alias ppio pp [a.__dict__ for a in %1]
# This tries to enable tab-completion of some identifiers.
!import rlcompleter
!pdb.Pdb.complete = rlcompleter.Completer(locals()).complete
# Taken from https://gist.github.com/1125049
# There are a couple of edge cases where you can lose terminal
# echo. This should restore it next time you open a pdb.
!import termios, sys
!termios_fd = sys.stdin.fileno()
!termios_echo = termios.tcgetattr(termios_fd)
!termios_echo[3] = termios_echo[3] | termios.ECHO
!termios_result = termios.tcsetattr(termios_fd, termios.TCSADRAIN, termios_echo)
Run Code Online (Sandbox Code Playgroud)
需要进一步的研究来检查那里的标签完成是什么......
归档时间: |
|
查看次数: |
4873 次 |
最近记录: |