Select to view content in your preferred language

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

08-27-2012 12:57 PM
New Contributor II
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:  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

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
New 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.

Python Team
0 Kudos