title: "index" attribute - Python
body: <p>When I was reading this answer <a href="https://stackoverflow.com/a/9841401/5175044">https://stackoverflow.com/a/9841401/5175044</a> to a question on removing duplicates from a string, I couldn't understand what the <code>index</code> attribute meant in </p>
  
  <pre><code>''.join(sorted(set(foo), key=foo.index)) 
  </code></pre>
  
  <p>I did this example run:</p>
  
  <pre><code>foo = "Wicked long string"
  &gt;&gt;&gt; "".join(sorted(set(foo),key = foo.index))
  'Wicked longstr'
  &gt;&gt;&gt; "".join(sorted(set(foo)))
  ' Wcdegiklnorst'
  </code></pre>
  
  <p>which leads me to think that it helps in keeping the order of the characters.</p>