1, in learning Linux children's shoes are used to the tab completion function, so in learning Python at the same time, one is for convenience, two can see more about the knowledge of the Python command.
2. Configuration steps:
(1) Type this code under Linux:
Vim 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
(2) View path
[[Email protected] ~] #python
Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "Help", "copyright", "credits" or "license" for more information.
>>> Import Sys
>>> Sys.path
[', '/usr/lib64/python26.zip ', '/usr/lib64/python2.6 ', '/usr/lib64/python2.6/plat-linux2 ', '/usr/lib64/python2.6/ Lib-tk ', '/usr/lib64/python2.6/lib-old ', '/usr/lib64/python2.6/lib-dynload ', '/usr/lib64/python2.6/site-packages ' , '/usr/lib64/python2.6/site-packages/gtk-2.0 ', '/usr/lib/python2.6/site-packages ']
The default path for Python is:/usr/lib/python2.6
(3) Copy the above script to the default path
CP Tab.py/usr/lib/python
3. Operation:
Import tab in Python view, i.e.:
Import tab
Summary: The above is a simple Python tab completion configuration.
Python tab completion function code under Linux