On Feb 27, 8:55 pm, Paul Rubin <http://[EMAIL PROTECTED]> wrote:
> Paul Rubin <http://[EMAIL PROTECTED]> writes:
> > def unique(seq, keepstr=True):
> >     t = type(seq)
> >     if t==str:
> >         t = (list, ''.join)[bool(keepstr)]
> >     seen = []
> >     return t(c for c in seq if (c not in seen, seen.append(c))[0])
>
> Preferable:
>
> def unique(seq, keepstr=True):
>     t = type(seq)
>     if t==str:
>         t = (list, ''.join)[bool(keepstr)]
>     seen = []
>     return t(c for c in seq if not (c in seen or seen.append(c)))

Wow, nice! Very cool. :)

Regards,
Jordan

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to