I'm tyring to write a script the allow me to select a layer by location, then calculate a field of the selected feature. But I'm having issue with CalculateField_management
.
Here part of the script:
farmsArea = r"pathFeature"
enclaves = r"pathFeature"
# Select by location --> farms within Enclaves
arcpy.SelectLayerByLocation_management(farmsArea, 'INTERSECT', enclaves, "", 'NEW_SELECTION')
# Calculate field "within enclaves = (here i have an issue, the name "yes" is not defined)
arcpy.CalculateField_management(farmsArea, 'within_enc', 'yes', 'PYTHON3')
# Switch selection and calculate "within enclaves = no"
arcpy.SelectLayerByAttribute_management(farmsArea, 'SWITCH_SELECTION')
arcpy.CalculateField_management(farmsArea, "'within_enc'", "no" )
# Clear selection
arcpy.SelectLayerByAttribute_management(farmsArea, 'CLEAR_SELECTION')
As error I have row 8 "name 'yes' is not defined"
'"yes"'