def UniqueIterator(iterator, key=(lambda x: x)):
 so_far = set()
 def no_dups(x):
  k = key(x)
  if (k in so_far):
   return False
  else:
   so_far.add(k)
   return True
 return IteratorFilter(iterator, no_dups)

def UniqueIterator ( iterator , key = ( lambda x : x ) ) : so_far = set ( ) def no_dups ( x ) : k = key ( x ) if ( k in so_far ) : return False else : so_far . add ( k ) return True return IteratorFilter ( iterator , no_dups )
takes an iterator and returns an iterator that returns only the first occurence of each entry .