Tips & Tricks: FieldExists for ArcGIS 10 Python

Here is a way to check if a Field in a feature class already exists or not. I was looking for an existing ArcGIS Esri function / tool but couldn’t find one so I wrote my own.

def FieldExist(featureclass, fieldname):
    fieldList = arcpy.ListFields(featureclass, fieldname)

    fieldCount = len(fieldList)

    if (fieldCount == 1):
        return True
        return False

This is a function and it assumes you have already set the workspace environment.


        if (not FieldExist(myFeatureClass, "myField")):
          arcpy.AddError("Field 'myField' does not exist in " + myFeatureClass)

hope this is helpful.


  1. Uhhhhhhhhhh! Good tool gangster

  2. Darryl Klassen

    another way to do it:
    if “myfield” in [ for f in arcpy.ListFields(myFeatureClass)]:

    • bjornkuiper

      thanks, that looks even easier. although the user should do an if-not. Anyway, it seems you have a good grasp of the python language. Thanks!