<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: AttributeError with arcpy.AddMessage when printing field object defaultValue property in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/attributeerror-with-arcpy-addmessage-when-printing/m-p/1283259#M67531</link>
    <description>&lt;P&gt;Figured it out shortly after original post.&lt;/P&gt;&lt;P&gt;ArcPy does not like a None value as input parameter for the AddMessage() function, replaced with string formatting below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

## path to feature class
fc = r"C:\Path\To\GDB\FeatureClass"

## describe the data and return a dictionary
desc = arcpy.da.Describe(fc)

## for each field object in the fields property
for field_obj in desc["fields"]:
    ## print the field name
    arcpy.AddMessage(field_obj.name)
    ## print the field defaultValue
    arcpy.AddMessage("{0}".format(field_obj.defaultValue))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;The defaultValue property was returning None for some fields. If you run the below it will throw the AttributeError, seen in original post, showing that the input to the AddMessage function must be convertible to a string.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;## AttributeError
arcpy.AddMessage(None)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 27 Apr 2023 11:25:56 GMT</pubDate>
    <dc:creator>Clubdebambos</dc:creator>
    <dc:date>2023-04-27T11:25:56Z</dc:date>
    <item>
      <title>AttributeError with arcpy.AddMessage when printing field object defaultValue property</title>
      <link>https://community.esri.com/t5/python-questions/attributeerror-with-arcpy-addmessage-when-printing/m-p/1283258#M67530</link>
      <description>&lt;P&gt;ArcGIS Pro 3.1 (also same error tested on 2.9)&lt;/P&gt;&lt;P&gt;Getting an&amp;nbsp;AttributeError when using arcpy.AddMessage() to print the default values for fields.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;AttributeError: Object: Error in parsing arguments for AddMessage&lt;/LI-CODE&gt;&lt;P&gt;Original code...&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

## path to feature class
fc = r"C:\Path\To\GDB\FeatureClass"

## describe the data and return a dictionary
desc = arcpy.da.Describe(fc)

## for each field object in the fields property
for field_obj in desc["fields"]:
    ## print the field name
    arcpy.AddMessage(field_obj.name)
    ## print the field defaultValue
    arcpy.AddMessage(field_obj.defaultValue)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 27 Apr 2023 11:18:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/attributeerror-with-arcpy-addmessage-when-printing/m-p/1283258#M67530</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2023-04-27T11:18:57Z</dc:date>
    </item>
    <item>
      <title>Re: AttributeError with arcpy.AddMessage when printing field object defaultValue property</title>
      <link>https://community.esri.com/t5/python-questions/attributeerror-with-arcpy-addmessage-when-printing/m-p/1283259#M67531</link>
      <description>&lt;P&gt;Figured it out shortly after original post.&lt;/P&gt;&lt;P&gt;ArcPy does not like a None value as input parameter for the AddMessage() function, replaced with string formatting below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

## path to feature class
fc = r"C:\Path\To\GDB\FeatureClass"

## describe the data and return a dictionary
desc = arcpy.da.Describe(fc)

## for each field object in the fields property
for field_obj in desc["fields"]:
    ## print the field name
    arcpy.AddMessage(field_obj.name)
    ## print the field defaultValue
    arcpy.AddMessage("{0}".format(field_obj.defaultValue))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;The defaultValue property was returning None for some fields. If you run the below it will throw the AttributeError, seen in original post, showing that the input to the AddMessage function must be convertible to a string.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;## AttributeError
arcpy.AddMessage(None)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2023 11:25:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/attributeerror-with-arcpy-addmessage-when-printing/m-p/1283259#M67531</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2023-04-27T11:25:56Z</dc:date>
    </item>
  </channel>
</rss>

