MikeEdwards

Retrieving first value in list

Discussion created by MikeEdwards on Oct 20, 2017
Latest reply on Dec 12, 2017 by rzufelt

I'm trying to extract the first value from a list. I'm using [0] but it seems to be returning all the values regardless. Am I overlooking something?

 

env.workspace = r"someSDEconnection.sde"

addModDate_featureList = arcpy.ListFeatureClasses("GEO*")
for addModDate_feature in addModDate_featureList:
   fc_result = arcpy.GetCount_management(addModDate_feature)
   fc_count = int(fc_result.getOutput(0))
   if fc_count == 0:
      print(addModDate_feature + " No Geometry Present")
   else:
      addModDate_field_names = [f.name for f in arcpy.ListFields(addModDate_feature)]
      if "MOD_DATE" in addModDate_field_names:
      unique_addDate = set(row[0] for row in arcpy.da.SearchCursor(addModDate_feature, "MOD_DATE"))
      outList = []
      for element in unique_addDate:
         if element is None:
            pass
         elif element is not None and element not in outList:
            outList.append(element)
            outList.sort(reverse=True)
            outList_recent = outList[0]
            print(addModDate_feature + " " + outList_recent)

         else:
              print(addModDate_feature + " No Date")

Outcomes