<?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: ArcPy equivelant to set([list]) in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-equivelant-to-set-list/m-p/613519#M47834</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Will return: &lt;STRONG&gt;set(['a'])&lt;/STRONG&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;Only because everything is wrapped in the &lt;/SPAN&gt;&lt;STRONG&gt;set()&lt;/STRONG&gt;&lt;SPAN&gt; Python class.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;gt;&amp;gt;&amp;gt;myList = list(set(['a','b','c','f','h','a','c','c','c','t']))
&amp;gt;&amp;gt;&amp;gt;myList[0]
'a'
&amp;gt;&amp;gt;&amp;gt;for item in set(['a','b','c','f','h','a','c','c','c','t']):
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print item
a
c
b
f
h
t&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;An important point is that &lt;/SPAN&gt;&lt;STRONG&gt;set()&lt;/STRONG&gt;&lt;SPAN&gt; objects are unordered, so if order is important one should also wrap everything in &lt;/SPAN&gt;&lt;STRONG&gt;sorted()&lt;/STRONG&gt;&lt;SPAN&gt;. Please let me know if I'm not understanding the issue correctly.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 02:14:19 GMT</pubDate>
    <dc:creator>PhilMorefield</dc:creator>
    <dc:date>2021-12-12T02:14:19Z</dc:date>
    <item>
      <title>ArcPy equivelant to set([list])</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-equivelant-to-set-list/m-p/613514#M47829</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a python script that works fine as a stand-alone python script.&amp;nbsp; In an effort to integrate it as a tool in ArcGIS however, it's not working.&amp;nbsp; After some research, I came across a forum thread that stated the python variable type 'set' is not usable in Arcpy.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there an alternative to make this work?&amp;nbsp; Some way of expressing set(&lt;UL&gt;) in arcpy?&lt;/UL&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Basically I have a feature class with features that intersect a selected point.&amp;nbsp; Some of these features have duplicate names.&amp;nbsp; the script is designed to take the names out of the intersecting features, and append them into a 'name' field in the point feature class.&amp;nbsp; To avoid having duplicate data names, I used set(&lt;UL&gt;) in Python to go through the list of features that are intersecting, and weed out the duplicates.&amp;nbsp; So eg, my list originally was list = [a,b,c,f,h,a,c,c,c,t].&amp;nbsp; Using set(list), it becomes [a,b,c,f,h,t].&amp;nbsp; I then convert it to string, make it look all fancy and nice, and throw it into the 'name' field of my point featureclass.&lt;/UL&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;any help is appreciated.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 May 2012 15:14:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-equivelant-to-set-list/m-p/613514#M47829</guid>
      <dc:creator>StephenKruzik</dc:creator>
      <dc:date>2012-05-08T15:14:23Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy equivelant to set([list])</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-equivelant-to-set-list/m-p/613515#M47830</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Stephen,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try one of the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
List = ['a','b','c','f','h','a','c','c','c','t']
List = dict.fromkeys(List)
List = List.keys()
print List&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;or&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;List = ['a','b','c','f','h','a','c','c','c','t']
outlist = []
for element in List:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if element not in outlist:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outlist.append(element)
print outlist&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:14:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-equivelant-to-set-list/m-p/613515#M47830</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-12T02:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy equivelant to set([list])</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-equivelant-to-set-list/m-p/613516#M47831</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;it worked.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 May 2012 16:15:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-equivelant-to-set-list/m-p/613516#M47831</guid>
      <dc:creator>StephenKruzik</dc:creator>
      <dc:date>2012-05-08T16:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy equivelant to set([list])</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-equivelant-to-set-list/m-p/613517#M47832</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm a little confused by this question. In what way are Python set objects incompatible with arcpy?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 May 2012 16:51:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-equivelant-to-set-list/m-p/613517#M47832</guid>
      <dc:creator>PhilMorefield</dc:creator>
      <dc:date>2012-05-08T16:51:50Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy equivelant to set([list])</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-equivelant-to-set-list/m-p/613518#M47833</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I'm a little confused by this question. In what way are Python set objects incompatible with arcpy?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Phil,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When returning a set object from a list I run into the problem of receiving "set('value')" instead of simply 'value'.&amp;nbsp; Ex:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;List = ['a','b','c','f','h','a','c','c','c','t']
List = dict.fromkeys(List)
List = List.keys()
print List[0]&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Will return: &lt;/SPAN&gt;&lt;STRONG&gt;a&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;List = ['a','b','c','f','h','a','c','c','c','t']
print set(List[0])&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Will return: &lt;/SPAN&gt;&lt;STRONG&gt;set(['a'])&lt;/STRONG&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:14:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-equivelant-to-set-list/m-p/613518#M47833</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-12T02:14:16Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy equivelant to set([list])</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-equivelant-to-set-list/m-p/613519#M47834</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Will return: &lt;STRONG&gt;set(['a'])&lt;/STRONG&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;Only because everything is wrapped in the &lt;/SPAN&gt;&lt;STRONG&gt;set()&lt;/STRONG&gt;&lt;SPAN&gt; Python class.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;gt;&amp;gt;&amp;gt;myList = list(set(['a','b','c','f','h','a','c','c','c','t']))
&amp;gt;&amp;gt;&amp;gt;myList[0]
'a'
&amp;gt;&amp;gt;&amp;gt;for item in set(['a','b','c','f','h','a','c','c','c','t']):
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print item
a
c
b
f
h
t&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;An important point is that &lt;/SPAN&gt;&lt;STRONG&gt;set()&lt;/STRONG&gt;&lt;SPAN&gt; objects are unordered, so if order is important one should also wrap everything in &lt;/SPAN&gt;&lt;STRONG&gt;sorted()&lt;/STRONG&gt;&lt;SPAN&gt;. Please let me know if I'm not understanding the issue correctly.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:14:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-equivelant-to-set-list/m-p/613519#M47834</guid>
      <dc:creator>PhilMorefield</dc:creator>
      <dc:date>2021-12-12T02:14:19Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy equivelant to set([list])</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-equivelant-to-set-list/m-p/613520#M47835</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;if you're running directly from a python script independant of ArcGIS, then yes, it works just fine.&amp;nbsp; That was actually my problem.&amp;nbsp; I was running my script as a stand-alone using the IDLE window to process everything.&amp;nbsp; I got tired of having to navigate to the file everytime though, so I tried to add it as a tool within Arctoolbox.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you process it from the Arcpy window within ArcMap, or as a tool script that requires much closer interaction with ArcGIS, then set(&lt;UL&gt;) will not work.&lt;/UL&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Open up the Python window within ArcMap and try it.&amp;nbsp; That's probably the best way to see it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 May 2012 17:49:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-equivelant-to-set-list/m-p/613520#M47835</guid>
      <dc:creator>StephenKruzik</dc:creator>
      <dc:date>2012-05-09T17:49:47Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy equivelant to set([list])</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-equivelant-to-set-list/m-p/613521#M47836</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;if you're running directly from a python script independant of ArcGIS, then yes, it works just fine.&amp;nbsp; That was actually my problem.&amp;nbsp; I was running my script as a stand-alone using the IDLE window to process everything.&amp;nbsp; I got tired of having to navigate to the file everytime though, so I tried to add it as a tool within Arctoolbox.&lt;BR /&gt;&lt;BR /&gt;If you process it from the Arcpy window within ArcMap, or as a tool script that requires much closer interaction with ArcGIS, then set(&lt;UL&gt;) will not work.&lt;BR /&gt;&lt;BR /&gt;Open up the Python window within ArcMap and try it.&amp;nbsp; That's probably the best way to see it.&lt;BR /&gt;&lt;SPAN&gt;I'm still not seeing any errors. The &lt;/SPAN&gt;&lt;STRONG&gt;set()&lt;/STRONG&gt;&lt;SPAN&gt; class is working normally for me in the ArcMap Python window (see attached). I'm using AGD 10, service pack 4, with the spatial join patch.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Are you importing any other libraries like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;from (some Python library) import *&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;The only thing I can think of is the name space might be polluted and you're calling a different &lt;/SPAN&gt;&lt;STRONG&gt;set&lt;/STRONG&gt;&lt;SPAN&gt; function or class.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You mentioned a thread in a forum that discussed this issue. Do you still have a link to that? A screenshot of the error would be helpful too.&lt;/SPAN&gt;&lt;/UL&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 May 2012 18:13:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-equivelant-to-set-list/m-p/613521#M47836</guid>
      <dc:creator>PhilMorefield</dc:creator>
      <dc:date>2012-05-09T18:13:54Z</dc:date>
    </item>
  </channel>
</rss>

