remove duplicates from list *preserving order*

Steven Bethard steven.bethard at gmail.com
Sun Feb 6 15:08:32 EST 2005


Francis Girard wrote:
> I think your last solution is not good unless your "list" is sorted (in which 
> case the solution is trivial) since you certainly do have to see all the 
> elements in the list before deciding that a given element is not a duplicate. 
> You have to exhaust the iteratable before yielding anything.

I don't follow.  The first time I see an element, it is not a duplicate, 
so I yield it.  After that, the element should show up in the 'seen' 
list, which means I won't yield any of the remaining equivalent 
elements.  Could you explain your logic here?

Steve



More information about the Python-list mailing list