def crossproduct(ss, row=None, level=0):
 if (row is None):
  row = []
 if (len(ss) > 1):
  return reduce(operator.add, [crossproduct(ss[1:], (row + [i]), (level + 1)) for i in ss[0]])
 else:
  return [(row + [i]) for i in ss[0]]

def crossproduct ( ss , row = None , level = 0 ) : if ( row is None ) : row = [ ] if ( len ( ss ) > 1 ) : return reduce ( operator . add , [ crossproduct ( ss [ 1 : ] , ( row + [ i ] ) , ( level + 1 ) ) for i in ss [ 0 ] ] ) else : return [ ( row + [ i ] ) for i in ss [ 0 ] ]
returns the cross-product of the sets given in ss .