Re[2]: [Tutor] Select distinct item form list

antonmuhin at rambler.ru antonmuhin at rambler.ru" <antonmuhin@rambler.ru
Mon Feb 24 07:29:02 2003


Hello Michael,

Monday, February 24, 2003, 12:46:06 PM, you wrote:

MJ> On Mon, 24 Feb 2003 janos.juhasz@VELUX.com wrote:

>>>> l
MJ> (1, 2, 3, 4, 5, 5, 6, 7, 7, 7, 2)
>>>> def uniqs(inp, was_there=[]):
MJ> ...   if not inp in was_there:
MJ> ...     was_there.append(inp)
MJ> ...     return 1  # sending "True" to filter
MJ> ...

It should be a little bit quickier with dictionaries or sets (in
Python2.3).

I seems to remebemer a long thread about uniq elements in tutor list
or python list.

Somewhat more trcikier solution:

def unisq(seq):
    return dict(zip(seq, [None,]*len(seq))).keys()

But it doesn't preserve order.

-- 
Best regards,
 anton                            mailto:antonmuhin@rambler.ru