A really slick way that I use to return rows as dicts is:
def rows_as_dicts(cursor):
colnames = cursor.fields
uc = hasattr(cursor, 'updateRow')
for row in cursor:
row_object = dict(zip(colnames, row))
yield row_object
if uc:
cursor.updateRow([row_object[colname] for colname in colnames])
Use this generator function like so:
with arcpy.da.SearchCursor(fc, ['*']) as sc:
for row in rows_as_dicts(sc):
x = row['MAPNAME']
blah ...
This works with both da.SearchCursors and UpdateCursors. In the later case, it will update each row. I got the idea for this from a posting on Cafe Python and modified it to be able to determine which type of cursor is passed to the generator. Excellent idea from Jason or one other ESRI Python guys.Mike