Please help- Delete Feature Class sample script

Discussion created by harmons4 on Feb 8, 2011
Latest reply on May 3, 2011 by mwarn5qa
Hi- I'm very new to ArcPy. I am trying to write a script that will list all the point feature classes in my gdb and then delete them. I have found some examples, but can't get it to run. Your help is much appreciated.

import arcpy

arcpy.env.workspace = r"E:\KingCounty.gdb"

import string


    fcList = arcpy.ListFeatureClasses("","point", "")
    for fc in fcList:
        Lst = arcpy.Describe(fc)
        if string.lower(Lst.shapeType) == "point":        
            print str(fc) + " is a " + Lst.shapeType + " feature class"
            print str(fc) + "The shapetype is unknown"

    print "Script failed"

# Set local variables
inFeatures = "points"
outFeatures = r"E:\output.gdb\new_points"
tempLayer = "pointsLayer"
expression = arcpy.AddFieldDelimiters(pointsLayer, "Point_ID") + " = 'busstop'" + " = 'bridges'"

    # Execute CopyFeatures to make a new copy of the feature class
    arcpy.CopyFeatures_management(inFeatures, outFeatures)

    # Execute MakeFeatureLayer
    arcpy.MakeFeatureLayer_management(outFeatures, tempLayer)

    # Execute SelectLayerByAttribute to determine which features to delete
    arcpy.SelectLayerByAttribute_management(tempLayer, "NEW_SELECTION",

    # Execute GetCount and if some features have been selected, then
    #  execute DeleteFeatures to remove the selected features.
    if arcpy.GetCount_management(tempLayer) > 0:
except Exception, e:
    # If an error occurred, print line number and error message
    import traceback, sys
    tb = sys.exc_info()[2]
    print "Line %i" % tb.tb_lineno
    print e.message