def xuniqueCombinations(items, n):
    """Return a list of unique combinations of items in list.

    >>> list(xuniqueCombinations([1, 2, 3], 1))
    [[1], [2], [3]]
    >>> list(xuniqueCombinations([1, 2, 3], 2))
    [[1, 2], [1, 3], [2, 3]]
    >>> list(xuniqueCombinations([1, 2, 3], 3))
    [[1, 2, 3]]
    """

    if n == 0:
        yield []
    else:
        for i in xrange(len(items)):
            for cc in xuniqueCombinations(items[i + 1:], n - 1):
                yield [items[i]] + cc
dataset/ETHPy150Open CGATOxford/cgat/CGAT/SetTools.py/xuniqueCombinations/original