def _product(*args, **kwds):
pools = list(map(tuple, args)) * kwds.get('<STR_LIT>', <NUM_LIT:1>)<EOL>result = [[]]<EOL>for pool in pools:<EOL><INDENT>result = [x+[y] for x in result for y in pool]<EOL><DEDENT>return result<EOL>
Generates cartesian product of lists given as arguments

From itertools.product documentation