List = ['a','b','c','f','h','a','c','c','c','t'] List = dict.fromkeys(List) List = List.keys() print List
List = ['a','b','c','f','h','a','c','c','c','t'] outlist = [] for element in List: if element not in outlist: outlist.append(element) print outlist
I'm a little confused by this question. In what way are Python set objects incompatible with arcpy?
List = ['a','b','c','f','h','a','c','c','c','t'] List = dict.fromkeys(List) List = List.keys() print List[0]
List = ['a','b','c','f','h','a','c','c','c','t'] print set(List[0])
Will return: set(['a'])
>>>myList = list(set(['a','b','c','f','h','a','c','c','c','t'])) >>>myList[0] 'a' >>>for item in set(['a','b','c','f','h','a','c','c','c','t']): ... print item a c b f h t
if you're running directly from a python script independant of ArcGIS, then yes, it works just fine. That was actually my problem. I was running my script as a stand-alone using the IDLE window to process everything. I got tired of having to navigate to the file everytime though, so I tried to add it as a tool within Arctoolbox.
If you process it from the Arcpy window within ArcMap, or as a tool script that requires much closer interaction with ArcGIS, then set() will not work.
Open up the Python window within ArcMap and try it. That's probably the best way to see it.
I'm still not seeing any errors. The set() 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.
Are you importing any other libraries like this:from (some Python library) import *
The only thing I can think of is the name space might be polluted and you're calling a different set function or class.
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.