Python's Way "first": Python Basics (5)

Source: Internet
Author: User

Python 3.2.3 and the following versions do not have their own tab completion, and the Python 3.5.1 comes with the tab completion module. #!/usr/bin/env python# python startup fileimport sysimport readlineimport rlcompleterimport atexitimport os# tab Completi Onreadline.parse_and_bind (' Tab:complete ') # History filehistfile = Os.path.join (os.environ[' HOME '], '. Pythonhistory ' ) Try:readline.read_history_file (histfile) except IOError:passatexit.register (Readline.write_history_file, Histfile) del os, Histfile, ReadLine, rlcompleter #for Linux import sysimport readlineimport rlcompleter If sys.platform = = ' Darwin ' and sys.version_info[0] = = 2:readline.parse_and_bind ("Bind ^i rl_complete") else:readline.parse_and_bind ("Tab:complete") # Linux and Python3 on Mac #for mac >>> import sys>>> print (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 '] >>>I write the tab.py module can only be imported in the current directory, if you want to use in any place in the system, to put this tab.py in the Python Global environment variable directory, is generally placed in the Python/2.7/site-packages directory, This directory does not have the same location in different OS, and print (Sys.path) allows you to view a list of Python environment variables.  ", which represents the current path, first find the current path 

Python's Way "first": Python Basics (5)

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.