Select to view content in your preferred language

SearchCursor won't reset?

3590
4
Jump to solution
08-13-2012 02:25 PM
RobertMartin2
Deactivated User
I am trying to get my feet wet with Python but something has me stumped. I made a test feature class with just one object and used that to instantiate a cursor. I looped over the FC and told it to print some text each time, which it did. I then reset the cursor and tried doing the same thing again but nothing prints. This is how my code looks:

>>> rows = arcpy.SearchCursor("pyLateralLine") >>> for row in rows: ...     print "something"


Can anyone think of what I'm doing wrong here? Thanks!
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JasonScheirer
Esri Alum
Calling .reset() is sketchy as best (it doesn't work on certain storage formats), you'll want to create a new SearchCursor object pointing to the same data.

View solution in original post

0 Kudos
4 Replies
JasonScheirer
Esri Alum
Calling .reset() is sketchy as best (it doesn't work on certain storage formats), you'll want to create a new SearchCursor object pointing to the same data.
0 Kudos
PriscillaCole
Occasional Contributor

Can you elaborate? Which storage formats don't work with .reset()?

0 Kudos
BruceBacia
Frequent Contributor
rows = arcpy.SearchCursor("pyLateralLine")
for row in rows:
    print "something"
del row
del rows
0 Kudos
BruceBacia
Frequent Contributor
maybe you could try the del row,rows ?
0 Kudos