Super simple Python command line tab One-click completion method

Source: Internet
Author: User

Friends who play Linux, still worry about Python's default no-tab completion?

Below is a solution in the next, hoping to help newcomers to the new school of Python.

First step: Write a one-click completion script tab.py

[Email protected]~] #vim tab.py

#!/usr/bin/env python

Import Sys

Import ReadLine

Import Rlcompleter

Import atexit

Import OS

#tab completion

Readline.parse_and_bind (' Tab:complete ')


Step Two: Enter Python interactive mode to view the selection order of the Python module import

[[email protected] ~]# python

Python 2.7.5 (Default, Nov 20 2015, 02:00:19)

[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] 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 ']

>>>


Step three: Copy one-click completion script to the Python module default path/usr/lib64/python2.7

[Email protected] ~]CP tab.py/usr/lib64/python2.7/


Fourth step: Import one-click completion module

[[email protected] ~]# python

Python 2.7.5 (Default, Nov 20 2015, 02:00:19)

[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2

Type "Help", "copyright", "credits" or "license" for more information.

>>> Import Tab

>>> Import Sys

>>> sys. --Double tab

Sys.__class__ (Sys.exitfunc (

SYS.__DELATTR__ (sys.flags

...

This article is from the "Miao Sen" blog, please be sure to keep this source http://zhaom0109.blog.51cto.com/11675013/1888024

Super simple Python command line tab One-click completion method

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.