AnsweredAssumed Answered

arcpy.CalculateField_management - compare: how to return fieldvalues

Question asked by DMMotti on Dec 4, 2018
Latest reply on Dec 5, 2018 by LukeW


I use a python script to compare the value of a field like follows:

def compare(class1):

   if class1 in (612, 611):
       return "Text1"
   elif class1 == 617:
       return "Text2"
       return !Field!

(followed by arcpy.CalculateField_management....)

this works perfectly to return a standardized text like "Text 1" or "Text 2".


But what I really want to do is I want to return a field-value instead of a text.

If (612, 611) return Field1-value;

if (617) return Field2-value.


I tried it with !Field! instead of "Text 1" but it didn't work.


What's the code to return a fieldvalue instead of text?


Thanks for your help!