[Tutor] Select distinct item form list

Gerrit Holl gerrit@nl.linux.org
Mon Feb 24 05:19:02 2003


janos.juhasz@VELUX.com schreef op maandag 24 februari om 08:39:31 +0000:
> Dear All,
> 
> Can someone show me a simple list comprehension to do the same thing as
> "Select distinct item form list" does in SQL
> 
> So i have a list
> >>> l = (1,2,3,4,5,5,6,7,7,7,2)
> but i would have just
> l=(1,2,3,4,5,6,7)
> 
> I know i have seen this somewhere, but i cannot find it :(

The best solution, and explanation, can be found in the Python Cookbook.
It is by Tim Peters: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52560

yours,
Gerrit.

-- 
Asperger Syndroom - een persoonlijke benadering:
	http://people.nl.linux.org/~gerrit/
Het zijn tijden om je zelf met politiek te bemoeien:
	http://www.sp.nl/