hasValue = 0 for rows in arcpy.SearchCursor("featureClass", "FIELD_NAME = 'some value'", None, "FIELD_NAME"): # if a record was read it matched the value of the query, so set as true and break out hasValue = 1 break # clean up cursor del rows if hasValue: # value was found else: # value was not found
rows = arcpy.SearchCursor("featureClass", "", "", "FIELD_NAME")
row = rows.next()
if row.FIELD_NAME = "some value":
# go on
Jalopena, this worked like a charm! I was already using the first suggestion which did not work, as you pointed out. I'd like to clarify for others that the 'del rows' should be tabbed over once or you'll get an error message. Greatly appreciated.
I don't know who Jalopena is, but if you are responding to my post I should point out that del rows should not be indented once to prevent an error, because it is meant to execute outside of the for loop after the break. Instead if you used my original post I failed to comment out the line that read "Clean Up Cursor", which would produce an error. You avoided that error by indenting it under the break so it never executed. I have placed a comment where it belongs. Please remove the Clean up cursor line and dedent just the del rows statement and try it again. If you still get an error I want to know, because you definitely are supposed to del the cursor at the level I originally posted, otherwise your table is left locked until Python decides to do clean up on its own.
Retrieving data ...