Python in Practice

In this section of the tutorial we are going to focus on some of the practical applications to which Python can be put, and the library modules that help us do that. This will involve learning about some background technologies such as databases, computer networks and the world wide web, as well as the basic features of the operating system that drives your computer. Because this is supposed to be a programming tutorial I will only cover the bare bones of these technologies and provide links to other sites where the curious can find out more.

The topics I have chosen reflect the areas that seem to crop up most often on the Python tutor mailing list, and therefore should be closest to the needs of new programmers. If your particular area of interest is not covered then the final topic may provide links to suitable sites where you will find what you need.

Finally, the topics in this section are all based on Python exclusively. There may be similar capabilities available in JavaScript and VBScript but the differences are far greater than the similarities at this level of detail. For example the easiest way to access the Windows operating system from JavaScript or VBScript is via the Windows Script Host discussed earlier but that is completely different in approach to Python's os module. Comparisons would be meaningless.

The topics

The specific topics I will be covering along with some idea of the depth of coverage are listed below:

Working with Data
The need to store and retrieve complex sets of data is one that most programmers come across at some stage. While Python provides several methods of storing simple data easily the most powerful storage mechanism is a full relational database. This topic will cover the principles behind relational databases and the SQL language used to manipulate them. It will conclude with a very simple example of using such a database from within Python.
Using the Operating System
The operating system is the basis of everything we do with a computer and it is very common that in the middle of a program we want to do the sort of things we do as a user everyday. For example, we might want to copy or move files, or create a folder, or start another program, or print a document. Fortunately the operating system exposes a programmable interface as well as a user interface and in this topic we will look at some of the features available to us, especially in the areas of traversing file structures and working with the environment.
Inter-process communications
Most beginner programs consist of a single computer process running in isolation, however as the systems we build get more powerful it is often better to split the program into separate parts each running in its own process, often using a technique known as client-server design. Or sometimes we simply want to access another program's output. In this module we will look at the basic principles and then illustrate an example of each of the two types described.
Network programming
The internet has connected computers all over the globe, but how can one computer communicate with another from within a program? It turns out that there are lots of ways to do this but here we will consider the most basic mechanism available in Python, the socket. Built on top of the socket are higher level mechanisms and we will go on to look at two of these: the email interface for sending and reading email messages and the ftp module for transferring files over a network.
Writing web clients
Having mastered basic network programming we now come onto the most common form of networking today: The World Wide Web. It turns out that python provides modules that make web programming easy. In this first topic on the subject we look at automating basic web tasks such as fetching information from a web site on a regular basis without resorting to a browser.
Writing Web Applications
In this topic we turn from the web user perspective to the web site creators view. We consider how to write a basic web application. In this case we will put a web interface onto the address book example we have been building since the early days of the tutor.
Parallel processing
As programs get more complex it is often the case that the simple sequential model of execution that we have discussed up until now is not sufficient. We want to do several things at once. This is where a technique called threading comes into play, and we will look at how to use Python's threading module to build parallel processing into a program.
Previous  Next  Contents


If you have any questions or feedback on this page send me mail at: alan.gauld@yahoo.co.uk