--- a/src/pyams_utils/list.py Tue Nov 15 10:43:55 2016 +0100
+++ b/src/pyams_utils/list.py Fri Nov 18 15:28:54 2016 +0100
@@ -23,7 +23,11 @@
def unique(seq, idfun=None):
"""Extract unique values from list, preserving order
- Original list is not modified.
+ :param list seq: input list
+ :param callable idfun: an identity function which is used to get 'identity' value of each element
+ in the list
+ :return: list; a new list containing only unique elements of the original list in their initial order.
+ Original list is not modified.
>>> from pyams_utils.list import unique
>>> mylist = [1, 2, 3, 2, 1]
@@ -35,6 +39,7 @@
[3, 2, 1, 4]
You can also set an 'id' function applied on each element:
+
>>> mylist = [1, 2, 3, '2', 4]
>>> unique(mylist, idfun=str)
[1, 2, 3, 4]