Select to view content in your preferred language

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

388
1
08-27-2012 12:57 PM
JamesMudd1
Emerging Contributor
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.
Tags (2)
0 Kudos
1 Reply
JasonPardy
Emerging Contributor
Hi James,

Thanks for posting this. It did find its way to the Python team. We apologize for the mistake.
You are correct, the square brackets should be not be used. We will fix this immediately.

Sincerely,
Python Team
0 Kudos