I did not realize that I should have been deleting cursors after accessing attribute tables until today. Up until now I never did this, but I've noticed that there are lots of file locks after my script runs (I presume it was a bad practice on my part to begin with). ArcGIS 10 help tells me that I should use the following code:
# Delete cursor and row objects to remove locks on the data
#
del row
del rows
I'm doing that in the following function:
# calculate areas
def area_calc( shapefile ):
"calculates geometric properties of each building"
# loop through attribute table
Rows = ARCPY.UpdateCursor( shapefile )
for row in Rows:
geom = row.Shape
polyArea = geom.area
row.setValue( perimName, 0 ) # set to zero
polyPerim = geom.length
row.setValue( areaName, polyArea ) # update area value
row.setValue( perimName, polyPerim ) # update perimeter value
Rows.updateRow(row)
# Delete the row and cursor
del row
del Rows
ARCPY.AddMessage( 'Area and Perimeter calculated for each polygon' )
However, when I do that I get the following error message:
Traceback (most recent call last):
File "LoopModuleBuildingAnalysis.py", line 9, in <module>
import ConstructionMaterialPhase1
File "D:\Code\AnalysisPhase1.py", line 101
del row
^
SyntaxError: invalid syntax
Press any key to continue . . .
Any suggestions what I should be doing? Thanks in advance.

rowis seen later in the program, as it seems to be out of scope. – djq Mar 3 '11 at 14:12del row, though it's still crashing half-way through running and I see locks on earlier files, so I'm not sure.... – djq Mar 3 '11 at 15:07