Change the method of the Python command line Interactive prompt.
I. Customize the Python interactive prompt
The default interactive prompt of Python is ">>>", but it can be customized.
After Python is started, find the PYTHONSTARTUP environment variable and then execute the Execution Code specified by the variable in this file.
Some Linux release packages provide the default startup script, which is generally stored in the home directory named. pythonstartup. The "Tab complete" and "command history" functions enhance the prompt application, both of which are based on the readline module.
If you do not have the. pythonstartup file, you can create one by yourself.
Simple Example:
Copy codeThe Code is as follows:
# Python startup file
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)
Handle t IOError:
Pass
Atexit. register (readline. write_history_file, histfile)
Del OS, histfile, readline, rlcompleter
You can set it to .pythonstartupat http://pypi.python.org/pypi/pbp.scripts.
Set the PYTHONSTARTUP environment variable
If you are running Python in Linux or Mac OS X, the easiest way is to create a STARTUP script and save it to the home directory.
Connect to the environment variable PYTHONSTARTUP and set it to the system startup script. For example, in Bash and Korn shell, you can use the. profile file. You can insert rows, for example:
Export PYTHONSTARTUP = ~ /. Pythonstartup
In windows, you can easily set the PYTHONSTARTUP gold variable.
Ii. iPython
See iPython: http://ipython.scipy.org
IPython aims to create a comprehensive environment for interactive applications and research and computing. IPython has two main components:
1) An enhanced Python Interactive shell
2) interactive parallel computing architecture
IPython open-source, current version: 0.9.1. It is an enhanced shell of Python. Features:
-Dynamic Object check
-Access the system shell from the prompt
-Direct support for Profiling
-Convenient debugging
Iii. Python distutils
Python comes with a set of tools distutils for publishing Python applications. It provides:
1. a skeleton
Provides standard metadata domains, such as the author name and License type.
2. A set of Helper
Understand how to create a release package.
Distutils does not provide the ability to define other dependent packages, which is enhanced by the setuptools tool.
Setuptools framework, which is a sub-project of Python Enterprise Application Kit (PEAK. Setuptools replaces the standard distutils library and adds version-based packages and dependency management for Python.
Perl users are familiar with CPAN, while Ruby users are familiar with Gems. The ez_setup tool of setuptools and the extended easy_install and Cheeseshop (Python Package Index, also known as "PyPI. In addition, setuptools also allows us to package our library into a package called "egg", which is similar to Java? The JAR file is similar, but it is used in Python.
To install setuptools, use EasyInstall.
EasyInstall is a package download tool and installer. EasyInstall is a supplement to the setuptools tool because it knows how to process build a package.