Relative Field Values in For Loop

Discussion created by tagiles on Mar 15, 2012
Latest reply on Mar 15, 2012 by Dan_Patterson
My issue is trying to retrieve field values inside a for loop:

#userFile - type FeatureLayer
userFile = arcpy.GetParameterAsText(0)

#user selects field from userFile - type Field "obtained from [userFile]"
userField = arcpy.GetParameterAsText(1)

#start cursor
rows = = arcpy.SearchCursor(userFile)

#inside loop, report all values of field [userField]
for row in rows:
        arcpy.AddMessage("Analyzing zone " + row.userField)

Python wants userField to be a hard coded value for the field. It won't accept it as a variable set by the user. Any way I can accomplish this?