Re: Cartesian Product of two lists (itertools)

2009-01-25 Thread Mark Wooding
Thorsten Kampe writes: > [((1, 4), 7), ((1, 4), 8), ((1, 5), 7), ((1, 5), 8), ((2, 4), 7), ((2, > 4), 8), ((2, 5), 7), ((2, 5), 8)] [...] > What's the best way to pre-process the arguments to "itertools.product" > or to post-process the result of "itertools.product" to get what I > want?! P

Re: Cartesian Product of two lists (itertools)

2009-01-25 Thread Terry Reedy
Thorsten Kampe wrote: Hi, is there a way to make itertools.product generate triples instead of pairs from two lists? For example: list1 = [1, 2]; list2 = [4, 5]; list3 = [7, 8] from itertools import product list(product(list1, list2, list3)) [(1, 4, 7), (1, 4, 8), (1, 5, 7), (1, 5, 8), (2, 4

Re: Cartesian Product of two lists (itertools)

2009-01-25 Thread Mensanator
On Jan 25, 3:12�pm, Thorsten Kampe wrote: > Hi, > > is there a way to make itertools.product generate triples instead of > pairs from two lists? > > For example:>>> list1 = [1, 2]; list2 = [4, 5]; list3 = [7, 8] > >>> from itertools import product > >>> list(product(list1, list2, list3)) > > [(1,

Cartesian Product of two lists (itertools)

2009-01-25 Thread Thorsten Kampe
Hi, is there a way to make itertools.product generate triples instead of pairs from two lists? For example: >>> list1 = [1, 2]; list2 = [4, 5]; list3 = [7, 8] >>> from itertools import product >>> list(product(list1, list2, list3)) [(1, 4, 7), (1, 4, 8), (1, 5, 7), (1, 5, 8), (2, 4, 7), (2, 4, 8