Add tab complement function under Python terminal

Source: Internet
Author: User

#需求

For the convenience of work, we need to add the tab complement function under the Python terminal

#存放脚本路径

Pyhton2.6

/usr/lib/python2.6/site-packages/

Python2.7

/usr/lib/python2.7/dist-packages/

#脚本代码

[Email protected] ~]# cat/usr/lib/python2.6/site-packages/tab.pytry:import readlineexcept importerror:print ("Mod Ule ReadLine not available. ") Else:import rlcompleter readline.parse_and_bind ("Tab:complete")

#bashrc文件配置

[Email protected] ~]# tail-1/etc/bashrcexport pythonstartup= "/usr/lib/python2.6/site-packages/tab.py"

#注销重新登陆

[Email protected] ~]# Login

#测试

[[email protected] ~]# pythonpython 2.6.6  (r266:84292, jul 23 2015,  15:22:56)  [GCC 4.4.7 20120313  (red hat 4.4.7-11)] on linux2type   "Help",  "copyright",  "credits"  or  "license"  for more information.> >> import sys>>> sys.sys.__class__ (               sys.argv                     SYS.MAXINTSYS.__DELATTR__ (             sys.builtin_module_names    sys.maxsizesys .__dict__                 sys.byteorder                Sys.maxunicodesys.__displayhoOk__ (        sys.call_tracing (            sys.meta_pathsys.__doc__                  sys.callstats (               sys.modulessys.__excepthook__ (          sys.copyright                sys.pathsys.__format__ (              Sys.displayhook (            sys.path_hookssys.__ GETATTRIBUTE__ (       sys.dont_write_bytecode      Sys.path_importer_cachesys.__hash__ (                sys.exc_Clear (              sys.platformsys.__ Init__ (               sys.exc_info (                sys.prefixsys.__name __                sys.exc_type                 sys.ps1sys.__ new__ (                 Sys.excepthook (             sys.ps2sys.__ package__             sys.exec_prefix              SYS.PY3KWARNINGSYS.__REDUCE__ (              sys.executable               sys.setcheckinterval (sys.__reduce_ex__ (           sys.exit (                    sys.setdlopenflags (sys.__repr__ (                sys.flags                    sys.setprofile (sys.__setattr__ (             sys.float_info               sys.setrecursionlimit (sys.__sizeof__ (              sys.getcheckinterval (        sys.settrace (sys.__stderr__               Sys.getdefaultencoding (     sys.stderrsys.__stdin__                sys.getdlopenflags (          sys.stdinsys.__stdout__               sys.getfilesystemencoding (  sys.stdoutsys.__str__ (                 sys.getprofile (              sys.subversionsys.__subclasshook__ (        sys.getrecursionlimit (      sys.versionsys._clear_ Type_cache (      sys.getrefcount (             sys.version_infOsys._current_frames (        sys.getsizeof (               sys.warnoptionssys._getframe (               sys.gettrace (                sys.api_version              sys.hexversion               >>> sys.

Add tab complement function under Python terminal

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.