Update (2008-02-11): Kurt Schwehr is thinking about Python code quality too.
Stalking "Python GIS" with Google's blog search led me today to this:
import arcgisscripting gp = arcgisscripting.create() gp.toolbox = "analysis" # Set the workspace gp.workspace = "c:\\Houston\\CrimeData" # Call ListFeatureClasses fcs = gp.ListFeatureClasses( ) #loop through the feature classes and buffer fcs.reset() fc = fcs.next() while fc: outName = "buffered_" + fc gp.buffer(fc, outName, "500 Feet") fc = fcs.next()
What a joyless way to work with Python. The requirement that programmers call reset() and next() is also a sure recipe for bugs. Ideally, the "enumeration objects" would implement the iterator protocol, and you'd just do this:
Better yet, you're not going to need to pass an argument into the enumeration factory, so replace it with a property:
Tight. Of course, I've got plans to do it even better in a future release of WorldMill. Something like:
Windows users: save on slashes by using Python's raw (r) strings as I did above.