def all_subsets(ss):
    return chain(*map(lambda x: combinations(ss, x), list(range(0, len(ss) + 1))))
for subset in all_subsets(stuff):
    pass
How to get all possible combinations of a list’s elements?