title: Ordered Sets Python 2.7
body: <p>I have a list that I'm attempting to remove duplicate items from. I'm using python 2.7.1 so I can simply use the <strong>set()</strong> function. However, this reorders my list. Which for my particular case is unacceptable. </p>
  
  <p>Below is a function I wrote; which does this. However I'm wondering if there's a better/faster way. Also any comments on it would be appreciated. </p>
  
  <pre><code>    def ordered_set(list_):
  
          newlist = []
          lastitem = None
          for item in list_:
  
              if item != lastitem:
                  newlist.append(item)
                  lastitem = item
  
          return newlist
  </code></pre>
  
  <p>The above function assumes that none of the items will be <strong>None</strong>, and that the items are in order (ie, <strong>['a', 'a', 'a', 'b', 'b', 'c', 'd']</strong>)</p>
  
  <p>The above function returns <strong>['a', 'a', 'a', 'b', 'b', 'c', 'd']</strong> as <strong>['a', 'b', 'c', 'd']</strong>.</p>