Python配置tab自动补全功能

Python配置tab自动补全功能

# cat tab.py

#!/usr/bin/python
# python tab file
  
import sys
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

Python配置tab自动补全功能

# python

Python 2.7.5 (default, Jul 13 2018, 13:06:57) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

>>> import sys

>>> sys.path

['', '/usr/lib64/python27.zip', '/usr/lib64/python2.7', '/usr/lib64/python2.7/plat-linux2', '/usr/lib64/python2.7/lib-tk', '/usr/lib64/python2.7/lib-old', '/usr/lib64/python2.7/lib-dynload', '/usr/lib64/python2.7/site-packages', '/usr/lib64/python2.7/site-packages/gtk-2.0', '/usr/lib/python2.7/site-packages']

Python配置tab自动补全功能

# cp tab.py /usr/lib64/python2.7

Python配置tab自动补全功能

>>> import tab

>>> import sys

>>> sys.

sys.__class__(              sys.argv                    sys.long_info
sys.__delattr__(            sys.builtin_module_names    sys.maxint
sys.__dict__                sys.byteorder               sys.maxsize
sys.__displayhook__(        sys.call_tracing(           sys.maxunicode
sys.__doc__                 sys.callstats(              sys.meta_path
sys.__excepthook__(         sys.copyright               sys.modules
sys.__format__(             sys.displayhook(            sys.path
sys.__getattribute__(       sys.dont_write_bytecode     sys.path_hooks
sys.__hash__(               sys.exc_clear(              sys.path_importer_cache
sys.__init__(               sys.exc_info(               sys.platform
sys.__name__                sys.exc_type                sys.prefix
sys.__new__(                sys.excepthook(             sys.ps1
sys.__package__             sys.exec_prefix             sys.ps2
sys.__reduce__(             sys.executable              sys.py3kwarning
sys.__reduce_ex__(          sys.exit(                   sys.pydebug
sys.__repr__(               sys.exitfunc(               sys.setcheckinterval(
sys.__setattr__(            sys.flags                   sys.setdlopenflags(
sys.__sizeof__(             sys.float_info              sys.setprofile(
sys.__stderr__              sys.float_repr_style        sys.setrecursionlimit(
sys.__stdin__               sys.getcheckinterval(       sys.settrace(
sys.__stdout__              sys.getdefaultencoding(     sys.stderr
sys.__str__(                sys.getdlopenflags(         sys.stdin
sys.__subclasshook__(       sys.getfilesystemencoding(  sys.stdout
sys._clear_type_cache(      sys.getprofile(             sys.subversion
sys._current_frames(        sys.getrecursionlimit(      sys.version
sys._debugmallocstats(      sys.getrefcount(            sys.version_info
sys._getframe(              sys.getsizeof(              sys.warnoptions
sys._mercurial              sys.gettrace(               
sys.api_version             sys.hexversion              

 

-------------------------------------------------------------

作者:罗穆瑞

转载请保留此段声明,且在文章页面明显位置给出原文链接,谢谢!

------------------------------------------------------------------------------

如果觉得这篇文章对你有小小的帮助的话,记得在右下角点个“推荐”哦,博主在此感谢!

------------------------------------------------------------------------------

上一篇:2016英国国际安防展:科达定位高阶IP视频监控品牌


下一篇:Openssh版本升级(Centos6.7)