[Numpy-discussion] Tuple outer product?

Alan G Isaac aisaac at american.edu
Fri Sep 25 15:19:55 EDT 2009


I do not see what is wrong with itertools.product,
but if you hate it, you can use numpy.meshgrid:

>>> np.array(np.meshgrid([1,2,3],[4,5,6])).transpose()
array([[[1, 4],
         [1, 5],
         [1, 6]],

        [[2, 4],
         [2, 5],
         [2, 6]],

        [[3, 4],
         [3, 5],
         [3, 6]]])

Alan Isaac



More information about the NumPy-Discussion mailing list