这部分程序有什么作用(在Nubela 的 guthub上找到)?
def product(*args, **kwds):
"""
for py2.6< support (they lack itertools lib)
- http://docs.python.org/2/library/itertools.html#itertools.permutations
"""
pools = map(tuple, args) * kwds.get('repeat', 1)
result = [[]]
for pool in pools:
result = [x+[y] for x in result for y in pool]
for prod in result:
yield tuple(prod)
后来在程序中:
list(set((product(*[range(2) for _ in range(length)]))))