On 08/26/2015 03:16 PM, David Kupka wrote:
> https://fedorahosted.org/freeipa/ticket/5248
> 
> 

+def deduplicate(lst):
+    new_lst = []
+    s = set(lst)
+    for i in lst:
+        if i in s:
+            s.remove(i)
+            new_lst.append(i)
+
+    return new_lst
+

Imho, this method deserves a docstring or at least a comment. It is not
entrirely clear from the name, that its job is to remove the duplicates
while preserving the order of the entries.

Anyway, deduplication can be implemented in a more readable way:

>>> from collections import OrderedDict
>>> sample_list = [3,2,1,2,1,5,3]
>>> OrderedDict.fromkeys(sample_list).keys()
[3, 2, 1, 5]

Tomas

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to