Table of Contents
We have explored various parts of the Python language and now we will take a look at how all these parts fit together, by designing and writing a program which does something useful.
The problem is "I want a program which creates a backup of all my important files".
Although this is a simple problem, there is not enough information for us to get started with the solution. A little more analysis is required. For example, how do we specify which files are to be backed up? Where is the backup stored? How are they stored in the backup?
After analyzing the problem properly, we design our program. We make a list of things about how our program should and will work. In this case, I have created the following list.
The files and directories to be backed up are given in a list.
The backup must be stored in a main backup directory.
The files are backed up into a zip file.
The name of the zip archive is the current date and time.
We use the zip command available by default in any standard Linux/Unix distribution. Windows users can use the Info-Zip program. Note that you can use any archiving command you want as long as it has a command line interface so that we can pass arguments to it from our script.