There is my version too:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/438599
Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list
In article <[EMAIL PROTECTED]>,
Felipe Almeida Lessa <[EMAIL PROTECTED]> wrote:
>"list(set(x))" is the clear winner with almost O(1) performance.
Moral: in an interpreted language, use builtins as much as possible.
--
http://mail.python.org/mailman/listinfo/python-list
Tim Chase:
>Is there an obvious/pythonic way to remove duplicates from a
>list (resulting order doesn't matter,
Use a set.
http://www.python.org/doc/lib/types-set.html
--
René Pijlman
--
http://mail.python.org/mailman/listinfo/python-list
On 19/04/2006 1:31 AM, Tim Chase wrote:
> Is there an obvious/pythonic way to remove duplicates from a list
> (resulting order doesn't matter, or can be sorted postfacto)?
Google is your friend:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52560
--
http://mail.python.org/mailman/li
Tim Chase <[EMAIL PROTECTED]> writes:
> Is there an obvious/pythonic way to remove duplicates from a
> list (resulting order doesn't matter, or can be sorted
> postfacto)? My first-pass hack was something of the form
>
> >>> myList = [3,1,4,1,5,9,2,6,5,3,5]
> >>> uniq = dict([k,None for k in
You could do
>>> uniq = [x for x in set(myList)]
but that's not really any different than what you already have.
This almost works:
>>> uniq = [x for x in myList if x not in uniq]
except the r-val uniq isn't updated after each iteration.
Personally I think list(set(myList)) is as optimal as
Em Ter, 2006-04-18 às 10:31 -0500, Tim Chase escreveu:
> Is there an obvious/pythonic way to remove duplicates from a
> list (resulting order doesn't matter, or can be sorted
> postfacto)? My first-pass hack was something of the form
>
> >>> myList = [3,1,4,1,5,9,2,6,5,3,5]
> >>> uniq = dict(
Is there an obvious/pythonic way to remove duplicates from a
list (resulting order doesn't matter, or can be sorted
postfacto)? My first-pass hack was something of the form
>>> myList = [3,1,4,1,5,9,2,6,5,3,5]
>>> uniq = dict([k,None for k in myList).keys()
or alternatively
>>> uniq = list