<?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: is there a better way to test for a field and feature class type?? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/is-there-a-better-way-to-test-for-a-field-and/m-p/661299#M51375</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If all you want to do is put the correct field delimiters on a field name, take a look at the &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000v0000004n000000.htm"&gt;AddFieldDelimiters&lt;/A&gt;&lt;SPAN&gt; function.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 28 Apr 2011 16:54:14 GMT</pubDate>
    <dc:creator>LoganPugh</dc:creator>
    <dc:date>2011-04-28T16:54:14Z</dc:date>
    <item>
      <title>is there a better way to test for a field and feature class type??</title>
      <link>https://community.esri.com/t5/python-questions/is-there-a-better-way-to-test-for-a-field-and/m-p/661298#M51374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;here is some code that runs in an mxd from the tool box, the user chooses the layer to do a search on, the script tests the layer to see if the field to do the search on exists then tests the layer to see if it is from a file geodatabase or an sde database by checking wether the layer is versioned so that the field will have quotation marks around it in the selection query for a file geodatabase feature class&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;the script works, but is there a better way to test for these things?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;## Get the selection layer
SelLayer = arcpy.GetParameterAsText(0)


## Check to see if the selection layer has a FIELD field
try: Afld
except NameError:
&amp;nbsp;&amp;nbsp; pass
else:
&amp;nbsp;&amp;nbsp; del Afld
&amp;nbsp;&amp;nbsp; 
for flds in arcpy.ListFields(SelLayer, "FIELD"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; Afld = True

try: Afld
except NameError:
&amp;nbsp;&amp;nbsp; arcpy.AddMessage(r"!! There is no FIELD field in %s, please select a layer with an FIELD field !!"%(SelLayer))
&amp;nbsp;&amp;nbsp; quit()
else:
&amp;nbsp;&amp;nbsp; del Afld

## set the ALTKEY field based on the layer type
check = arcpy.Describe(SelLayer)
if check.isVersioned:
&amp;nbsp;&amp;nbsp; FLD = "FIELD"
else:
&amp;nbsp;&amp;nbsp; FLD = '"FIELD"'&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Apr 2011 16:30:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-a-better-way-to-test-for-a-field-and/m-p/661298#M51374</guid>
      <dc:creator>FrankVignati</dc:creator>
      <dc:date>2011-04-28T16:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: is there a better way to test for a field and feature class type??</title>
      <link>https://community.esri.com/t5/python-questions/is-there-a-better-way-to-test-for-a-field-and/m-p/661299#M51375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If all you want to do is put the correct field delimiters on a field name, take a look at the &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000v0000004n000000.htm"&gt;AddFieldDelimiters&lt;/A&gt;&lt;SPAN&gt; function.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Apr 2011 16:54:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-a-better-way-to-test-for-a-field-and/m-p/661299#M51375</guid>
      <dc:creator>LoganPugh</dc:creator>
      <dc:date>2011-04-28T16:54:14Z</dc:date>
    </item>
  </channel>
</rss>

