codeblock @ arcpy.CalculateField_management

Discussion created by RPvermkv on Oct 11, 2013
Latest reply on Oct 11, 2013 by SWendel-esristaff

I have a table named "street" with a column named "Kategorie", filled with values "0..6". I added a new column named "RULE". I want to fill this column with strings depending on "KATEGORIE". I have a PY-Script and it doesn't work. What is wrong.
I think the problem is the line "expression" or "codeblock". I try to print the result of "myval".The result is a error message "name myval is not defined"

Thank you for your help !

expression = "getKat(!KATEGORIE!)"
codeblock = """def getKat(KATEGORIE):
    if KATEGORIE == "0":
        myval == "Autobahn"
    elif KATEGORIE == "1":
        myval == "Bundesstrasse"
        myval == "3"
    return myval"""
print "myval", myval
arcpy.CalculateField_management(ERG, "RULE", expression, "PYTHON", codeblock)