7.2. A Module Test Harness for xgrep

Python actively encourages programmers to split programs into modules. A Python program typically imports all or part of many other modules. These can be a mixture of standard modules, user-defined modules, or third-party modules.[1]

[1] There are a great many of these modules. See http://www.python.org/download/Contributed.html.

Frequently, a Python module that can be imported into another program is also a useful standalone application. The xgrep utility, for example, will obviously have a useful life as a command-line tool as well as being a candidate module for inclusion in larger programs.

Imagine for a moment that the main entry point to xgrep is the function XMLGrep. In the example below, a larger program ...

Get XML Processing with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.