[Numpy-discussion] combinatorics

Sam Tygier Sam.Tygier@hep.manchester.ac...
Thu Mar 4 05:20:22 CST 2010


itertools in the python standard library has what you need

>>> import itertools
>>> list( itertools.product([4,5], [7,8,9]) )
[(4, 7), (4, 8), (4, 9), (5, 7), (5, 8), (5, 9)]

(all the itertools functions return generators, so the list() is to
convert it to a list)

Sam



More information about the NumPy-Discussion mailing list