I am running ArcMap 10.4.1. I am running a script that uses a DA search cursor nested inside an update cursor to assign variables from values in a table. The script then writes those same variables to a feature class in the update cursor. I have done this many times in the past, but now I am getting a tuple assignment error when I try to assign row values in the update cursor. I know tuples aren't mutable and I am not trying to assign values in the search cursor. What is the problem here? This syntax has worked many times in the past.

The script fails on the first attempted row assignment after the search cursor:

row[2] = tblAppAdd
TypeError: 'tuple' object does not support item assignment

Here is the script portion (edited for length):

with arcpy.da.UpdateCursor(u'lyr_patientsPts', fcFields) as fieldsCursor:
    for row in fieldsCursor:        

        appID = unicode(row[1])

        # This is a custom function I found to simplify writing SQL search statements
        # for the where_clause in the search cursor.
        tblWhere = WhereClauseFromList(tblPatients, u'APPLICATION_ID', [appID])

        # Get values of the fields in the table to put into the points feature class
        with arcpy.da.SearchCursor(tblPatients, tblFields, where_clause = tblWhere) as tblCursor:

            for row in tblCursor:
                tblAppAdd = unicode(row[2])
                tblAppCity = unicode(row[3])
                tblAppState = unicode(row[4])
                # ... etc there are ten more fields

        # Write values from table to points feature class
        row[2] = tblAppAdd
        row[3] = tblAppCity
        row[4] = tblAppState        
        # etc

  • 2
    Try calling your SearchCursor iterator something like sRow since you're already using row for the UpdateCursor.
    – Evan
    Commented Oct 25, 2016 at 20:25
  • 5
    Nested cursors are generally frowned upon. The typical approach is to use a search cursor first to create a dictionary of the key/value pairs you need (in your case from tblPatients), then reference the dictionary from within the update cursor.
    – Bjorn
    Commented Oct 25, 2016 at 20:41

1 Answer 1


First, you reassigned row. Change row to srow for the search cursor and row to urow for the update cursor.

The error you're getting is that you're trying to update the search cursor object (since it got reassigned). The arcpy.da.search cursor returns a tuple, and update cursor returns a list.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.