AnsweredAssumed Answered

CalculateField_management Expression Question

Question asked by GEOlson86 on Sep 18, 2013
Latest reply on Sep 18, 2013 by rutzmosh
I'm trying understand the CalculateField_management tool and I guess I just don't understand how to properly define a field to be a variable.  I'm just working in the Python Window for now, attempting to get my expression to work.  I'm just using a test shapefile until I understand how the function works, so I just have "FIELD1", "FIELD2", "FIELD3", AND "FIELD4" and when I run my expression I receive an error saying it can't concatenate 'str' and 'int' objects. Obviously this is a problem because all of my attribute fields are set up as number fields, 1 and 2 are short and 3 and 4 are double.  So do I need a line to define each column as a number since it seems to be defaulting to strings?  Here is my line:

arcpy.CalculateField_management("pythontesting", "FIELD3", ("FIELD1" + 1) * "FIELD2", "PYTHON")


That doesn't work, but if I replace my expression with 8 * 4, then I get the calculated value of 32.  What am I doing wrong?

Outcomes