AnsweredAssumed Answered

Variable usage in codeblock

Question asked by wtgeographer on Oct 2, 2014
Latest reply on Oct 2, 2014 by jskinner-esristaff

I am receiving the error that variable row is not defined (second line of codeblock). I am attempting to check "constraints_Merge_fl" against code value in "lepc_clip_fl". What does the correct usage of this variable in the codeblock look like?


    fc = "lepc_clip"
    code = "CODE"
    field = "OBJECTID"

    # Make fl's for select tools
    arcpy.MakeFeatureLayer_management(fc,fc + "_fl")

    cursor = arcpy.SearchCursor(fc + "_fl")
    row =


    chat_List = []
    while row:
        code_Value = row.getValue(code)
        hex_ID = row.getValue("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)
                                    return code"""
            arcpy.CalculateField_management("constraints_Merge_fl", "CODE", expression, "PYTHON_9.3", codeblock)

        row =


Thanks in advance.