fc = "lepc_clip"
code = "CODE"
field = "OBJECTID"
# Make fl's for select tools
arcpy.MakeFeatureLayer_management(fc,fc + "_fl")
arcpy.MakeFeatureLayer_management("constraints_Merge","constraints_Merge_fl")
cursor = arcpy.SearchCursor(fc + "_fl")
row = cursor.next()
arcpy.AddField_management("constraints_Merge_fl","HEX_ID","Long")
chat_List = []
while row:
code_Value = row.getValue(code)
hex_ID = row.getValue("Hex_ID")
chat_List.append(hex_ID)
for feature in chat_List:
arcpy.SelectLayerByAttribute_management (fc + "_fl","NEW_SELECTION",'"Hex_ID" = {}' .format(feature))
arcpy.SelectLayerByLocation_management("constraints_Merge_fl",'intersect', fc + "_fl")
expression = "getClass(int(!CODE!))"
# Check syntax for row.getValue(code) in codeblock
codeblock = """def getClass(code):
if code < row.getValue(code):
return row.getValue(code)
else:
return code"""
arcpy.CalculateField_management("constraints_Merge_fl", "CODE", expression, "PYTHON_9.3", codeblock)
row = cursor.next()
Thanks in advance.