diff --git a/lib/utils.py b/lib/utils.py index a6b677c0b98344444647f18f20a231eaa2b4d421..014475524eff06ded6ce5650c1f684ad0d029e87 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -1477,6 +1477,12 @@ def any(seq, pred=bool): # pylint: disable-msg=W0622 return False +def partition(seq, pred=bool): # # pylint: disable-msg=W0622 + "Partition a list in two, based on the given predicate" + return (list(itertools.ifilter(pred, seq)), + list(itertools.ifilterfalse(pred, seq))) + + def UniqueSequence(seq): """Returns a list with unique elements.