the next article
new Python environment variable configuration file:
under the host user directory
vim. Pystartup
# ADD Auto-completion and a stored history file of commands to your Python
# Interactive interpreter. Requires Python 2.0+, ReadLine. Autocomplete is
# bound to the ESC key by default (you can change It–see readline docs).
# Store The file in ~/.pystartup, and set a environment variable to point
# to it: ' Export pythonstartup=~/.pystartup ' in bash.
Import atexit
Import OS
Import ReadLine
Import Rlcompleter
readline.parse_and_bind (' Tab:complete ')
Historypath = Os.path.expanduser ("~/.pyhistory")
def save_history (historypath=historypath):
Import ReadLine
readline.write_history_file (Historypath)
if Os.path.exists (historypath):
readline.read_history_file (Historypath)
Atexit.register (save_history)
del os, atexit, ReadLine, Rlcompleter, Save_history, Historypath
To set the python environment variable:
permanent entry into force:
echo "Export Pythonstartup=~/.pystartup" >>/etc/profile
Source/etc/profile
Verification:
[email protected] ~]# python27
Python 2.7.9 (default, June, 16:05:04)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "Help", "copyright", "credits" or "license" for more information.
>>> e
elif Else Enumerate (eval_r (except exec execfile (exit ) (
>>> e
This article is from the "Jinchuang" blog, make sure to keep this source http://jinchuang.blog.51cto.com/8690689/1844413
Add interactive mode tab autocomplete and command history functions for Python