[Tutor] Another example of Python at work

Kirby Urner urnerk@qwest.net
Tue, 19 Feb 2002 09:04:33 -0800


Just to toss out another example of a project wherein
Python is proving very useful as a "glue language",
I offer my:

  http://www.inetarena.com/~pdx4d/ocn/sphpacking.html

What's going on here is we have this Java applet that
packs spheres in a particular way.  We want to use its
data to feed another free software package called
Qhull, and we want to view the results using free
rendering software (Povray) and VRML.

So Python comes in and does all the mediation between
the apps, reading sphere data, doing computations,
passing data out to Qhull, reading it back in, and
so on.  It's the kind of thing that you want to do
fairly quickly, and without trying to memorialize the
whole process in some perfect code.  A little worse
(than perfect) is better in this case.

Also, thanks to object-orientation, it's natural to
define "Ball" objects which correspond to the balls
in the packing.  These get properties and methods
related to finding all nearby neighbors, and for
rendering the results.  Python fits the problem,
because it fits your brain (or mine at least).

Kirby