Python:获得 itertools.combinations 到 return 逐渐变大的组合

Python: get itertools.combinations to return progressively larger combinations

现在我正在使用:

list_one = ((1, 2), (3, 4), (5, 6), (7, 8), (9, 10))
list_two = []
print "List One: " + str(list_one)
for i in range(0, 5):
        list_two = tuple(c for i in range(len(list_one))
                           for c in itertools.combinations(list_one[:i], i))
print "List Two: " + str(list_two)

输出:

List One: ((1, 2), (3, 4), (5, 6), (7, 8), (9, 10))
List Two: ((), ((1, 2),), ((1, 2), (3, 4)), ((1, 2), (3, 4), (5, 6)), ((1, 2), (3, 4), (5, 6), (7, 8)))

我想要的是:

List One: ((1, 2), (3, 4), (5, 6), (7, 8), (9, 10))
List Two: ((), ((1, 2),), ((3, 4),), ((5, 6),), ((7, 8),), ((9, 10),), ((1, 2), (3, 4)), ((1, 2), (5, 6)), ((1, 2), (7, 8)), ((1, 2), (9, 10)), ((3, 4), (5, 6)), ((3, 4), (7, 8)) ... 

所以第一轮是单品
第二遍包括所有 2 项组合,包括 (1, 2) 等
第三遍包括所有 3 个项目组合,包括 (1, 2) 和 (3, 4) 等

简化版:

list_one = ((1), (2), (3), (4), (5))

会输出:

((1), (2), (3), (4), (5), ((1), (2)), ((1), (3)), ((1), (4)), ((1), (5)), ((2), (3)), ((2), (4))... ((3), (4), (5)))

如何修改使其移动自:
1 -> 2 -> 3 -> 4 -> 5
1,2 -> 1,3 -> 1,4 -> 1,5
...

干掉[:i]:

import itertools

list_one = ((1, 2), (3, 4), (5, 6), (7, 8), (9, 10))
list_two = []
print "List One: " + str(list_one)
for i in range(0, 5):
    list_two = tuple(c for i in range(len(list_one))
                     for c in itertools.combinations(list_one, i))
print "List Two: " + str(list_two)

输出:

List One: ((1, 2), (3, 4), (5, 6), (7, 8), (9, 10))
List Two: ((), ((1, 2),), ((3, 4),), ((5, 6),), ((7, 8),), ((9, 10),), ((1, 2), (3, 4)), ((1, 2), (5, 6)), ((1, 2), (7, 8)), ((1, 2), (9, 10)), ((3, 4), (5, 6)), ((3, 4), (7, 8)), ((3, 4), (9, 10)), ((5, 6), (7, 8)), ((5, 6), (9, 10)), ((7, 8), (9, 10)), ((1, 2), (3, 4), (5, 6)), ((1, 2), (3, 4), (7, 8)), ((1, 2), (3, 4), (9, 10)), ((1, 2), (5, 6), (7, 8)), ((1, 2), (5, 6), (9, 10)), ((1, 2), (7, 8), (9, 10)), ((3, 4), (5, 6), (7, 8)), ((3, 4), (5, 6), (9, 10)), ((3, 4), (7, 8), (9, 10)), ((5, 6), (7, 8), (9, 10)), ((1, 2), (3, 4), (5, 6), (7, 8)), ((1, 2), (3, 4), (5, 6), (9, 10)), ((1, 2), (3, 4), (7, 8), (9, 10)), ((1, 2), (5, 6), (7, 8), (9, 10)), ((3, 4), (5, 6), (7, 8), (9, 10)))