deleting fields from a shapefile doesn't work in my python script

Discussion created by wany9 on May 24, 2011
Latest reply on May 24, 2011 by wany9

# Import system modules
import sys, string, os, arcgisscripting

# Create the Geoprocessor object
gp = arcgisscripting.create(9.3)

# Set a default workspace
gp.workspace = "C:\\arcgisserver\\gisdata"

# Set a default workspace
gp.toolbox = "management"


fields = gp.ListFields("KY_TaxAreas.shp")

for field in fields:
        if field.Name not in KeepList:
                gp.deletefield("KY_TaxAreas.shp", "field.Name")
                print field.Name + " is deleted"

The whole processing seems right, and I got all print message for those fields which I want to delete. However, when I open the shapefile in ArcCatalog, those deleting fields are still there. Any idea?