Red Hat 7下python tab补全
最近学习python,总结一下如何添加shell脚本,达到(对象.)时,tab按2下调用所有方法的出现。1、首先在目录:/usr/lib64/python2.7/site-packages下面建立vim tab.py文件。
2、tab.py文件下面的内容:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/python
import os
import readline
import rlcompleter
import atexit
import os
# tab completion
readline.parse_and_bind('tab: complete')
# history file
histfile = os.path.join(os.environ['HOME'],'pythonhistory')
try:
readline.read_history_file(histfile)
except IOError:
pass
atexit.register(readline.write_history_file,histfile)
del os,histfile,readline,rlcompleter
然后:chmod 755 tab.py -----> ./tab.py(编译);
3、此时,在进入python的编译环境,在每次用到要补全函数前,必须事先导入这个包:import tab
示例:
以__开头的函数,是私有的,不能直接调用;就调用那些以字母开头的函数即可!!!
这样就达到了tab补全函数的功能了(前提:首先的导入tab模块,import tab);
页:
[1]