remove duplicates from list *preserving order*

Steven Bethard steven.bethard at gmail.com
Thu Feb 3 16:31:11 EST 2005


Carl Banks wrote:
> from itertools import *
> [ x for (x,s) in izip(iterable,repeat(set()))
>   if (x not in s,s.add(x))[0] ]

Wow, that's evil!  Pretty cool, but for the sake of readers of my code, 
I think I'll have to opt against it. ;)

STeVe



More information about the Python-list mailing list