<?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: gp.listfields Method in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/gp-listfields-method/m-p/155850#M12006</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;print [f.name for f in fields]&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 Mar 2011 18:04:50 GMT</pubDate>
    <dc:creator>JasonScheirer</dc:creator>
    <dc:date>2011-03-08T18:04:50Z</dc:date>
    <item>
      <title>gp.listfields Method</title>
      <link>https://community.esri.com/t5/python-questions/gp-listfields-method/m-p/155849#M12005</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Greetings,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Basic question... I'm trying to list out the names of all the fields in a particular shapefile.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Using the gp.listfields method in the following manner...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;fields = gp.listfields("[shapefile_location]")
print fields&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...I get a list of items resembling, "geoprocessing describe field object object at 0x032A2F0".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How can I print the actual field names?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;DR&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Mar 2011 17:54:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/gp-listfields-method/m-p/155849#M12005</guid>
      <dc:creator>DuncanRager</dc:creator>
      <dc:date>2011-03-08T17:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: gp.listfields Method</title>
      <link>https://community.esri.com/t5/python-questions/gp-listfields-method/m-p/155850#M12006</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;print [f.name for f in fields]&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Mar 2011 18:04:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/gp-listfields-method/m-p/155850#M12006</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2011-03-08T18:04:50Z</dc:date>
    </item>
    <item>
      <title>Re: gp.listfields Method</title>
      <link>https://community.esri.com/t5/python-questions/gp-listfields-method/m-p/155851#M12007</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Worked great, thanks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I'm getting a 'u' in front of each field name... what does that mean?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, is this method specific to anything, like the geoprocessing object maybe? In other words, if I had a simple list, say...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;silverware = ["forks", "knives", "spoons"]&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...and I input...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;print [f.name for f in silverware]&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...I would get an error. What's the difference between the lists? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;DR&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Mar 2011 18:15:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/gp-listfields-method/m-p/155851#M12007</guid>
      <dc:creator>DuncanRager</dc:creator>
      <dc:date>2011-03-08T18:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: gp.listfields Method</title>
      <link>https://community.esri.com/t5/python-questions/gp-listfields-method/m-p/155852#M12008</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;the u stands for unicode (just ignore it)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;gt;&amp;gt;&amp;gt; silverware = ["forks", "knives", "spoons"]
&amp;gt;&amp;gt;&amp;gt; for utensil in silverware:
...&amp;nbsp; print utensil
...&amp;nbsp; 
forks
knives
spoons
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;as for the "name" thing, your simple example above has no name property whereas a field has a name property as well as several others (eg type, precision, scale if appropriate etc etc)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:16:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/gp-listfields-method/m-p/155852#M12008</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T08:16:46Z</dc:date>
    </item>
    <item>
      <title>Re: gp.listfields Method</title>
      <link>https://community.esri.com/t5/python-questions/gp-listfields-method/m-p/155853#M12009</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;u means it is a Unicode object, as opposed to a regular (locale-specific) C-style string. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Doing this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;print [f.name for f in silverware]&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;is trying to get the name property off the string, which does not exist, hence the error.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Mar 2011 18:32:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/gp-listfields-method/m-p/155853#M12009</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2011-03-08T18:32:32Z</dc:date>
    </item>
  </channel>
</rss>

