The Python Programming Language
Python is an object-oriented programming language that has an easy syntax and high-level mechanisms for handling data. The language is used in some special applications (e.g. rapid prototyping, system integration, and software testing). Python can be used in Windows, Linux, Mac OS, and even in some small mobile devices.
I do not yet provide a book about Python, but through this link you can get Python versions of the programs that are presented in my programming books. This means, for example, that if you want to know how the program Game.java, that is presented in my Java book, can be written with the Python programming language, you can simply use the above link and you'll find a file named Game.py that contains the Python version of the program. The Python programs that you can find via the above link contain comments that should help you to get some basic information about the Python programming language.
The following links may be helpful when you are studying Python programming:
- Python documentation at www.python.org
- Exercises related to Python programming
Exercises in Finnish
- GUI programs that use the PyQt and PyGTK libraries
PyQt4 Class Reference
PyGTK 2.0 Reference
PyGTK 2.0 Tutorial
Python installation and execution of programs
If you are using a Linux, UNIX, or Mac OS computer, you do not probably need to install a Python compiler (interpreter) to your computer. Python is usually a standard tool in the mentioned operating systems. To execute the Python program Game.py in these operating systems, you need to open a Terminal window and go to the folder (directory) where you have put the Game.py file. Then you can type the command
which executes (or interprets) the Python program that is stored in file Game.py. (I use the word "interpret" when I'm writing about Python programs because Python programs are scripts that are not compiled in the traditional way. When a Python interpreter executes a program, the compilation and execution activities are carried out as a single process.)
If you are usign a Windows computer, you probably need to install the necessary Python tools. To make the installation, you should go to www.python.org and download a free installation file named python-2.4.3.msi. (The numbers in the file name may be larger.) By executing this file on your (Windows) computer, you can install the Python compiler and documentation related to Python. When I installed the Python compiler, I installed it to folder (directory) D:\Python24. After this I could run the Python program Game.py in the following way in a command prompt window:
This program is a computer game.
Please, type in an integer : 1234
You typed in 1234.
My number is 1235.
Sorry, you lost. I won. The game is over.
In the above case Game.py was in the folder D:\pythonfiles2. This may not the only way to run Python programs in Windows. Please, explore the tools that are installed when above-mentioned .msi file is executed, and you'll probably find easier ways to execute Python programs. It is also possible to execute a .py file by clicking on the file's icon but this usually terminates the program so quickly that you cannot see what it prints.
You can edit Python programs with the Notepad2 editor in Windows. The editor is able to highlight the Python syntax with several colors. Instructions for downloading and installing the Notepad2 editor are provided here.
www.python.org provides a lot of documentation related to Python. Some of these documents are installed to your Windows computer when you install the compiler.
PyQt Installation and Use
If you are using Linux, you probably need to install an additional software package to run PyQt.
In Windows, you first need the basic Python installation.
Then you need a corresponding binary for PyQt from
When you execute the .exe file, it installs PyQt to the same folder in which the basic Python was installed.
After this you can run PyQt applications simply by commanding in the following way:
The pictures below are obtained from a fan site of a British comedy group named Monty Python's Flying Circus. The "father" of the Python programming language is a Dutch man named Guido van Rossum, and he is a great fan of the mentioned comedy group. He named his programming language after his favourite comedians.