I have a script that works, but I replicate it in order to conditionally update 5 different fields. I would like to bolster the script to conditionally calculate all 5 fields into one if I can.
# Calculate Region
# Set local variables
inTable = nodeFeatures
inField = "Region1"
expression = "Reclass (!NodeID1!, !Region1!)"
codeBlock = """def Reclass (NodeID1, Region1):
if NodeID1 != None:
return region #variable is declared earlier in the script
else:
return None"""
# Execute CalculateField
arcpy.CalculateField_management(inTable, inField, expression, "PYTHON_9.3", codeBlock)
The script above works just fine, but as I mentioned, I end up duplicating it to calculate 4 other fields. In this example we'll call all 5 fields Region1, Region2, etc... They would all have an accompanying NodeID1, NodeID2, etc...
Is it possible to expand upon this script in order to reduce the 5 separate scripts to calculate them all in one, or is it just the way it has to be in order to calculate a value of completely separate fields?
Thanks in advance!