def product(*args, **kwds):
    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)
Установить продукты в Python