Set python command-line interactivity to auto-complement

Source: Internet
Author: User

  1. 1. Create a new Python environment variable configuration file:

    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 an environment variable to point# to it:  ' export Pythonstartup=~/.pystartup ' in Bash.import atexitimport OSI Mport readlineimport rlcompleterreadline.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

  2. 2. Set the python environment variable:

  3. Immediate effect, restart failure: Export Pythonstartup=~/.pystartup

  4. Permanently valid for the current User: echo "Export Pythonstartup=~/.pystartup" >> ~/.bash_profile

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Set python command-line interactivity to auto-complement

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.