[Freeipa-devel] [PATCH 0066] ipactl: Do not start/stop/restart single service multiple times
Tomas Babej
tbabej at redhat.com
Wed Aug 26 15:49:29 UTC 2015
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
More information about the Freeipa-devel
mailing list