test = ["a","b","c","d","e"]
def xuniqueCombinations(items, n):
if n==0: yield []
else:
for i in xrange(len(items)-n+1):
for cc in xuniqueCombinations(items[i+1:],n-1):
yield [items[i]]+cc
x = xuniqueCombinations(test, 3)
print x
usciteCome stampare ciò che penso sia un oggetto?
"generator object xuniqueCombinations at 0x020EBFA8"
voglio vedere tutte le combinazioni che ha trovato. Come lo posso fare?
due cose: http://docs.python.org/library/itertools.html e http://docs.python.org/glossary.html#term-generator – SilentGhost