Loop Fields and replace values based on an expression

Discussion created by parsonz on Apr 5, 2012
Latest reply on Apr 6, 2012 by mdenil

I have several columns within my dataset and i need to change the value of each row dependant on whether it is  =-1 or != -1.
My thoughts where to create a list of fields, loop through those and then use a search cursor to loop through each row and perform the expression.
The trouble I have is how I pass the field name to the row . I've posted my code below

import arcpy

input = r"C:\Users\Claire Parsons\Documents\GIS\Stratford LSA\Working\Stratford LSA.gdb\LCP\Stratford_3c_with_constraint_1" # your feature class

fieldList = arcpy.ListFields(input,"Max*") #create field list using only fields that begin with max

rows = arcpy.UpdateCursor(input) #create serach cursor

for field in fieldList:
        for row in rows:
        if row.? == -1: #how do i pass the field to the row?????
            row.? = 0
        elif row.? != -1:
            row.? = 1

print "\nDone.\n"

del row
del rows