26 Feb
2002
26 Feb
'02
4:16 p.m.
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. -- Oleg Broytmann http://phd.pp.ru/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.