A Byte of Python

Features of Python

Simple

Python is a simple and minimalistic language. Reading a good Python program feels like reading English, although very strict English! This pseudo-code nature of Python is one of its greatest strengths.

Easy to Learn

As we will discover in this book, Python is very easy to get started with and has an extraordinarily simple syntax.

Free and Open Source

Python is an example of an open source software. In simple terms, you can freely distribute copies of the software, read the source code, make changes to it and use pieces of it in new free programs. Open source is based on the concept of a community which shares knowledge. This is one of the reasons why Python is so good - it is constantly improved by a community which just wants to see a better Python.

High-level Language

When you write programs in Python, you do not need to bother about low-level details such as managing the memory used by your program, etc.

Portable

Due to its open source nature, Python has been ported to (i.e. changed to make it work on) many platforms. All your Python programs can work on any of these platforms without requiring any changes as long as you are careful to avoid any system-specific features.

You can use Python on Linux, Windows, FreeBSD, Macintosh, Solaris, OS/2, Amiga, AROS, AS/400, BeOS, OS/390, z/OS, Palm OS, QNX, VMS, Psion, Acron RISC OS, VxWorks, PlayStation, Sharp Zaurus, Windows CE, Pocket PC and even Nokia Series 60 mobile phones!

Interpreted

This term requires a bit of explanation.

A program written in a compiled language like C or C++ is converted from the source language (i.e. C or C++) into a language that is spoken by your computer (binary code i.e. 0s and 1s) using a compiler with various flags and options. When you run the program, the linker/loader software copies the program from the hard disk to memory and starts running it.

Python, on the other hand, does not need the compilation and linking/loading steps. You just run the program directly from source code. Internally, Python converts the source program into an intermediate form called bytecodes and then translates this into the native language of your specific system and then runs it. All this actually makes Python much easier to use since you do not have to worry about compiling the program, making sure the proper libraries are linked and loaded, etc. This also makes your Python programs more portable since you can just copy the program to another computer and it just works!

Object Oriented

Python supports both procedure-oriented programming as well as object-oriented programming.

In procedure-oriented programming, the program is built around procedures or functions which are just reusable pieces of programs to which data is fed. In object-oriented programming, the program is built around objects which combine both data and functionality.

Python has a very powerful but simplistic way of doing object-oriented programming, especially when compared to big languages like C++ or Java.

Extensible

If you need a critical piece of code in your program to run very fast or want to have a piece of algorithm to be hidden from the outside world, then you can write that part of the program in languages like C or C++ and then use that part from your Python programs.

Embeddable

You can embed Python in your programs written in other languages like C or C++ to give 'scripting' capabilities for your program's users.

Extensive Libraries

The Python Standard Library is huge. It can help you with regular expressions, documentation generation, unit testing, threading, databases, web browsers, CGI, FTP, email, XML, HTML, WAV files, cryptography, GUI using Tk, and many other system-specific functionality as well.

All these modules are part of the standard Python installation. This is called the 'Batteries Included' philosophy of Python.

Besides the standard library, there are various other high-quality libraries such as Twisted, Python Imaging Library, wxPython and many more available in the Internet.

Summary

Python has the right combination of performance and features that make writing programs both fun and easy.