[Tutor] Best Known Method for Filtering redundant list items.

Chris Hengge pyro9219 at gmail.com
Thu Nov 30 22:22:02 CET 2006


No problem at all, as I said, this doesn't matter for my needs since I'm
just posting values into a DB. Just curious why it jumbles it all up :)

On 11/30/06, Lloyd Kvam <lkvam at venix.com> wrote:
>
> There is a fly in the ointment that hit me after I sent the email.
> Using set does not preserve the order.  If you care about the order of
> elements in list1, my suggestion will not work.
>
>
> On Thu, 2006-11-30 at 16:01 -0500, Python wrote:
> > On Thu, 2006-11-30 at 12:51 -0800, Chris Hengge wrote:
> > > Anyone point me to something more efficient then
> > >
> > list2 = list(set(list1))
> >
> > Older Pythons will force you to import sets and use sets.Set
> >
> > > for item in list1:
> > >      if item not in list2:
> > >            list2.append()
> > >
> > > This just seems to take a bit a time when there are thousands or
> > > dozens of thousands of records just to filter out the dozen or so
> > > copies..
> > >
> > > Thanks.
> > > _______________________________________________
> > > Tutor maillist  -  Tutor at python.org
> > > http://mail.python.org/mailman/listinfo/tutor
> --
> Lloyd Kvam
> Venix Corp.
> 1 Court Street, Suite 378
> Lebanon, NH 03766-1358
>
> voice:  603-653-8139
> fax:    320-210-3409
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20061130/db3bdc23/attachment.html 


More information about the Tutor mailing list