def unique_combinations(items, n):
    """Return r-length tuples, in sorted order, no repeated elements"""
    if n==0: yield []
    else:
        for i in xrange(len(items)-n+1):
            for cc in unique_combinations(items[i+1:],n-1):
                yield [items[i]]+cc
dataset/ETHPy150Open adieu/allbuttonspressed/docutils/utils.py/unique_combinations/original