Suppose there are 2 categories if items: cat_1 = [1, 2], cat_2 = ['a', 'b']
, then I should get (1, 'a'), ('1', 'b'), (2, 'a'), (2, 'b')
. And if there is one more categories of items cat_3 = ['x', 'y']
, then the result should be (1, 'a', 'x'), (1, 'a', 'y'), ... (2, 'b', 'y')
.
It's easy to get all combination if the number of categories is a constant value, one can just get all combination by
[(i,j) for i in cat_1 for j in cat_2]
But I don't know what's the pythonic way to implement a function to generate all possible combination of various categories of items.