cursor error

4054
6
Jump to solution
02-15-2015 11:49 AM
PROBERT68
Frequent Contributor

On page 169 of the Programming ArcGIS 10.1 with Python cookbook.

 

Step 6  says to type this : for row in sorted(cursor):

 

But if you look at the number 04 which gave the error because PyScripter could not defined cursor ?

 

I have also type this 04 code into Python window and it showed it doesn't defined cursor is ....

 

 

import arcpy.da arcpy.env.workspace ="c:/ArcpyBook/Ch9" arcpy.da.SearchCursor("Schools.shp",("Facility","Name"))    for row in in sorted(cursor):     print("School name: " + row[1])
0 Kudos
1 Solution

Accepted Solutions
DarrenWiens2
MVP Honored Contributor

In any case, this is how I usually see and use da cursors:

>>> with arcpy.da.SearchCursor("YOUR_LAYER_HERE",("ID","FID")) as cursor:
...     for row in sorted(cursor):
...         print row

View solution in original post

6 Replies
DarrenWiens2
MVP Honored Contributor

You have two "in"s: "for row in in sorted(cursor):"

0 Kudos
DarrenWiens2
MVP Honored Contributor

In any case, this is how I usually see and use da cursors:

>>> with arcpy.da.SearchCursor("YOUR_LAYER_HERE",("ID","FID")) as cursor:
...     for row in sorted(cursor):
...         print row
PROBERT68
Frequent Contributor

Yes that worked !

0 Kudos
RachelGomez
New Contributor II

Let's check out some ways to fix this problem.
Double-Check Your Hardware. 
Double-Check Your Mouse's Surface. 
Change Touchpad Settings. 
Disconnect Other Devices. 
Run the Hardware Troubleshooter. 
Update Your Mouse's Drivers. 
Tame Your Mouse.

 

Regards,

Rachel Gomez

0 Kudos
PROBERT68
Frequent Contributor

Thank you however, this post was dated back in 2015. Hopefully others can test theirs.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

@RachelGomez , the original question had to do with ArcPy cursors and not computer mouse cursors, so checking hardware and mouse and trackpad settings would have no effect.