rmartin4

Python throwing syntax error

Discussion created by rmartin4 on Apr 24, 2012
Latest reply on Apr 24, 2012 by rmartin4
I have an extremely basic question that is driving me nuts. I have an attribute which I am trying to populate using the Field Calculator based on the value on another attribute. Let's call the condition attribute ATTRIBUTE_1 and the target attribute ATTRIBUTE_2. Here is the gist of my code:

Codeblock
first = !ATTRIBUTE_1!
second = None

if first == 20:
    second = 100
else:
    second = 200


ATTRIBUTE_2 =
second




This gives a syntax error. I tried rooting out the problem by reducing the entire process this:

Codeblock
first = !ATTRIBUTE_1!


ATTRIBUTE_2 =
first


...and I STILL get a syntax error. I can populate the field if I set "first" equal to some integer, so I'm guessing the problem is with the attribute but I'm not sure why. I've triple-checked all my types and everything is numeric. Furthermore, if I ignore the codeblock and do a simple ATTRIBUTE_2 = !ATTRIBUTE_1! the values copy fine. Does anyone know why something this simple would not be working?


Many thanks,
Robert

Outcomes