[Zope] ZCatalog results.

Sidnei da Silva sidnei@x3ng.com.br
Tue, 26 Feb 2002 13:51:00 -0300


Excuse me for my ignorance. I should have realized this at first sight, but i 
think i need to wash my face more strongly when i wake up....

[]'s Sidnei.

Em Ter 26 Fev 2002 13:16, Oleg Broytmann escreveu:
> On Tue, Feb 26, 2002 at 01:02:28PM -0300, Sidnei da Silva wrote:
> > How?
> >
> > > > seen = {}
> > > > unique = []
> > > > for r in result:
> > > >   if not seen.has_key(r.data_record_id_):
> > > >     seen[r.data_record_id_] = r.data_record_id_
> > > >     unique.append(r)
> > > >
> > > > return unique
> > > >
> > > > It works OK. Thanx everyone.
> > >
> > > You may reduce this to one dictionary :)
>
>    You want "unique" to contain unique records? The list of keys of a
> dictionary is exactly what you want!
>
> unique = {}
> for r in result:
>    if not unique.has_key(r.data_record_id_):
>       unique[r.data_record_id_] = r
> return unique.values()
>
>    The "if" test is not neccessary, actually :)
>
> Oleg.

-- 
Sidnei da Silva
X3ng Web Technology
sidnei@x3ng.com.br