Chapter 23: Python


Python is a scripting language. It was first released in 1991 by Guido van Rossum, who is still actively involved in maintaining and improving the language. Python is open source and runs on virtually all UNIX variants, including Linux, BSD, HP-UX, AIX, Solaris, and Mac OS X, as well as on Windows. (There’s even a version of Python for the PSP.) Python has been gaining popularity ever since it was released, and although Perl is still more widely used, it is certainly one of the most popular scripting languages. One reason for its popularity is the large set of libraries available for Python, including interfaces for writing graphical applications, and for network and database programming.

Like most scripting languages, Python has built-in memory management. Scripts are compiled to bytecode before they are interpreted, which makes execution fairly efficient. Python can be used to write either object-oriented or procedural code. It even supports some features of functional programming languages.

Writing programs in Python is typically faster and easier than writing in C. Python is known for being easy to combine with C libraries, however, and because it can be object-oriented, it works well with C++ and Java also. Python is significantly more readable than Perl. In particular, Python code strongly resembles pseudocode. It uses English words rather than punctuation whenever possible. Like Perl, Python is used extensively in developing applications for the web. Chapter 27 shows how Python can be used for CGI scripting and web development.

This chapter is only an introduction to the many uses of Python. It gives you all the information you need to get started writing your own Python scripts, but if you really want to understand Python, you will need to devote some time to a longer reference. See the section “How to Find Out More” at the end of this chapter for suggested sources.

Installing Python

Most modern UNIX systems come with python already installed, usually at /usr/bin/python. If it is installed on your system, the command python -V will tell you which version you have. If you do not have python installed, you can download it from http://www.python.org/, which is the official web site for Python. The download page includes instructions for unpacking and installing the source files.




UNIX. The Complete Reference
UNIX: The Complete Reference, Second Edition (Complete Reference Series)
ISBN: 0072263369
EAN: 2147483647
Year: 2006
Pages: 316

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net