epullium_usfs

How to use Python Pre-Logic in Field Calculator

Discussion created by epullium_usfs on Jan 7, 2013
Latest reply on Jan 8, 2013 by epullium_usfs
I am trying to use if/then python pre-logic in field calculator to only change the value of a field when one or two other fields equal a predefined value.  I can get it to work partially using the following code but it does not keep the original values for fields where "if=FALSE".  I have tried using "pass" but it does not seem to work the way I need it to.

Pre-logic:
def myfunc(SYMBOL,ID,OPER_MAINT_LEVEL):
    if ID == "4648" and OPER_MAINT_LEVEL == "1 - BASIC CUSTODIAL CARE (CLOSED)":
        return 4
    if ID == "4654":
        return 4
    if ID == "4663C" and OPER_MAINT_LEVEL == "1 - BASIC CUSTODIAL CARE (CLOSED)":
        return 4
    else:
        SYMBOL
SYMBOL=
myfunc( !SYMBOL!, !ID!, !OPER_MAINT_LEVEL! )

Outcomes