I wrote the following recursive routine to compute cross product of two sets.
def combine(input1,input2,output): if len(input2)==0: return output
Use itertools
import itertools print list(itertools.product(input1, input2))
Semantically this is equivalent to:
for i_1 in input_1: for i_2 in input_2: for i_3 in input_3: ... for i_n in input_n: #do something with i_1, i_2, i_3, ..., i_n
Where n is the number of arguments you pass to product.
product