jamespmudd

Typo in code example for arcpy.da.UpdateCursor()

Discussion created by jamespmudd on Aug 27, 2012
Latest reply on Aug 27, 2012 by jpardy-esristaff
I hope this thread can find an ESRI staff member who can get it fixed.  I don't really have the time or inclination at the moment to work through tech support to get it resolved.  I believe there is a typo in the code example on this page:  http://resources.arcgis.com/en/help/main/10.1/index.html#//002z0000001q000000.  About halfway down the table is an example for the updateCursor as follows:

import arcpy

# Create update cursor for feature class
#
with arcpy.da.UpdateCursor("c:/base/data.gdb/roads",
                           ["roadtype", "distance"]) as cursor:
    for row in cursor:
        # Update the values in the distance field by multiplying
        #   the rowtype by 100. Road type is either 1, 2, 3 or 4.
        #
        row[1] = row[0] * 100
        cursor.updateRow([row])

The final line should not contain brackets:  cursor.updateRow(row).  I'm not a Python expert, so it took me more than a solid day to find this error.  ESRI, typos in examples is not acceptable!  Examples should be tested and verified to run correctly.  Thank you.

Outcomes