Calculate field in python if else statement

Discussion created by louchios on Jan 21, 2014
Latest reply on Jan 22, 2014 by louchios
Hi I have the following code. Basically I am trying to say when the field "daily_minFlag" equals 's', then I want to calculate the "daily_min" field to be null.

    fieldName = "daily_min"
    expression = "getClass(!daily_minFlag!)"
    codeblock = """def getClass(minFlag):
        if minFlag == 's':
            return ""
            return !daily_min!"""
    arcpy.CalculateField_management(out_feature_class, fieldName, expression, "PYTHON_9.3", codeblock)

I am getting an error when using the else statement. If I replace "return !daily_min!" with "return 1", it works fine, but I don't want it to equal 1, I want it to not change the daily_min value. So I think there is something wrong with my !daily_min! syntax. Thank you.