Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Clarifying when cursor locks are released

$
0
0
Does the following line of code "release" the cursor?
Code:

#Note: rdsmall_lyr has a single selected feature
rdsmall_values = sorted(arcpy.da.SearchCursor(rdsmall_lyr, ["UA", "FAID_S", "CTCODE", "RTNUMBER", "AOTCLASS"]))

The help pages state that a cursor can be released by the completion of the cursor (http://resources.arcgis.com/en/help/...0000001q000000), but I'm not very confident in my understanding of an implicit release. Any insight would be greatly appreciated!
I do have an alternative approach that I'm confident tidies up after itself (below), but am hoping I can get away with the simpler code.
Code:

with arcpy.da.SearchCursor(rdsmall_lyr, ["UA", "FAID_S", "CTCODE", "RTNUMBER", "AOTCLASS"]) as road_cur:
    rdsmall_values = sorted(road_cur)


Viewing all articles
Browse latest Browse all 2485

Trending Articles