Make your own free website on

Python Utilities and Packages

On this page is a collection of Python code that I have written. To use the simple Python programs (*.py):
  1. Rename the program from "xxxx.html" to "".
  2. Add "#! /usr/local/bin/python" (or whatever similar line you use) asthe first line of the program.
  3. Remove any html code from the file. Usually this includes "<pre>" and "</pre>".

Essays and Utilities

mrquery : mrquery.06.01.22 finds duplicate images in image collections. The code implements a variation of the algorithm described in Fast Multiresolution Image Querying by Charles E. Jacobs, Adam Finkelstein and David H. Salesin. The paper can be found at CiteSeer.IST as mrquery.pdf.

A book on a related topic is A Wavelet Tour of Signal Processing by Stephane Mallat. See Chapter 10 for material that might explain why the Haar transform in mrquery works so well. But I don't understand this stuff very well.

The first version of mrquery contained a fatal bug. Don't use it.

MultiDict : is a module containing two classes, MultiDict and Table.

IM : The current version of IM is contained in mrquery. This version is based on numarray 1.5.0. Some of the capabilities of IM are:

Note: IM is pronounced with a long I.

Cgram : Cgram (cgram.tar.gz) is a half-finished (and buggy) program that semi-automatically writes Pyrex wrappers for C code starting with the C header files. I use ANTLR to parse the header files. As an intermediate step, man and Python readable parse trees are created.

SeeGramWrap : SeeGramWrap.2004.03.03.tar.gz is a heavily revised and upgraded version of the ANTLR C parser that is in cgram above. Many bugs have been fixed. The latest verson has been refactored to move some of the complexity from ANTLR to Python. SeeGramWrap.2004.09.24.tgz is a recent snapshot. Parts of it work.

Reference counting in Python : I find the own, borrow, steal metaphor for references in the Python documentation to be confusing. I rearranged the documentation and changed the metaphor in Reference Counting in Python.

Ascii Codes : Ascii makes a table of ASCII codes in decimal or hex.

Watch : Watch shows what happens when a small piece of code is executed. The code is executed in isolation. This is useful for explaining Python features. I wish there were a non-interactive debugger.

m * [n * [0]] : It is tempting to initialize m x n arrays using "m * [n * [0]]". Here is what happens if you do.

m * [n * [0]], Theory : Several fundamental rules of Python interact badly when processing the expression "m * [n * [0]]". Here I try to state these rules and give examples.

Documentation Keywords : A pair of simple programs illustrate problems with most computer documentation.

Searching HTML documentation : I find it very useful to be able to search the Python (or other) HTML documentation on my machine. pydocs.tar.gz does this.

Print a line number and a message Useful for debugging. See