import arcpy
arcpy.env.workspace = r'D:\Geodatabases\BD_VOCATION.gdb '
points = r'D:\Geodatabases\BD_VOCATION.gdb\Loc_vocation'
try:
arcpy.MakeFeatureLayer_management(points,'points_layer')
rows = arcpy.SearchCursor(points,'','',"OBJECTID", "OBJECTID D")
lst = []
for row in rows:
m = row.getValue("OBJECTID")
lst.append(m)
v = lst[0]
r = str(v)
query = """{0} = {1}""".format(arcpy.AddFieldDelimiters(points, "OBJECTID"), int(r))
arcpy.SelectLayerByAttribute_management("points_layer", "NEW_SELECTION", query)
except:
print "An error occured during selection"
This is what I meant for formatting. I indented the best I could but since I don't understand your logic Lines 13 and 14 may not be part of the for loop. However, that said, a few things jump out:
You should be using da.SearchCursor; I don't know if the original SearchCursor works any more.
You are mixing and matching between your feature class and your feature layer.
The syntax in line 6 even for the old search cursor isn't correct. I suggest you use the more 'traditional' syntax to a search cursor as shown in the help pages.Can you explain your logic in lines 9 through 12?
Finally, what is your end game? That is, what are you trying to accomplish?
That should just about do it....