title: Adding Values to an Array and getting distinct values using Python
body: <p>I have python code below that will loop through a table and print out values within a particular column.  What is not shown is the form in which the user selects a Feature Layer.  Once the Feature Layer is selected a second Dropdown is populated with all the Column Headings for that Feature and the user chooses which Column they want to focus on.  Now within the python script, I simply print out each value within that column.  But I want to store each value in a List or Array and get Distinct values.  How can I do this in Python?</p>
  
  <p>Also is there a more efficient way to loop through the table than to go row by row?  That is very slow for some reason.</p>
  
  <p>many thanks</p>
  
  <pre><code># Import system modules
  import sys, string, os, arcgisscripting
  
  # Create the Geoprocessor object
  gp = arcgisscripting.create(9.3)
  gp.AddToolbox("E:/Program Files (x86)/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx")
  
  # Declare our user input args
  input_dataset = sys.argv[1] #This is the Feature Layer the User wants to Query against
  Atts = sys.argv[2]          #This is the Column Name The User Selected
  
  #Lets Loop through the rows to get values from a particular column          
  
  fc = input_dataset
  
  gp.AddMessage(Atts)
  
  rows = gp.searchcursor(fc)
  row = rows.next()
  NewList = []
  
  for row in gp.SearchCursor(fc):
      ##grab field values
      fcValue = fields.getvalue(Atts)
      NewList.add(fcValue)
  </code></pre>