I want to extract the index of a field with its name using arcpy. It seems what I have written is so dumb. Is there any simpler method with out using for-loop?
import arcpy fieldList = arcpy.ListFields(self.address_ref_layer1) self.field_name =  for field in fieldList: self.field_name.append(field.name) #self.remove_pseudo_nodes() print self.field_name print self.field_name.index(u"NAMN1")
It could also be written:
fieldList = arcpy.ListFields(self.address_ref_layer1 name_index = [f.name for f in fieldList].index(u"NAMN1")
The ListFiled function returns list of field objects with many properties as well as name, but no function to return the index of the field which has a specific name?