Summary
Adds a warning message (severity of 1) to the messages of a script tool or Python toolbox tool.
When a tool is run, a warning message can be accessed from the Geoprocessing pane, the geoprocessing history, and the list of messages when a tool is called from Python.
Syntax
AddWarning (message)
Parameter | Explanation | Data Type |
message | The warning message. | String |
Code sample
Add a warning message to a Python script tool.
import arcpy
fc = arcpy.GetParameterAsText(0)
# Get the count from GetCount's Result object
feature_count = int(arcpy.GetCount_management(fc).getOutput(0))
if feature_count == 0:
arcpy.AddWarning("{0} has no features.".format(fc))
else:
arcpy.AddMessage("{0} has {1} features.".format(fc, feature_count))