[Numpy-discussion] how do I list all combinations

René Bastian rbastian at free.fr
Wed Dec 26 16:08:21 EST 2007


Le Mercredi 26 Décembre 2007 21:22, Mathew Yeates a écrit :
> Hi
> I've been looking at "fromfunction" and itertools but I'm flummoxed.
>
> I have an arbitrary number of lists. I want to form all possible
> combinations from all lists. So if
> r1=["dog","cat"]
> r2=[1,2]
>
> I want to return [["dog",1],["dog",2],["cat",1],["cat",2]]
>
> It's obvious when the number of lists is not arbitrary. But what if
> thats not known until runtime?
>
> Mathew

In the 'Reference Manual' of Python there is an example.

>
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion

-- 
René Bastian
http://www.musiques-rb.org
http://pythoneon.musiques-rb.org
http://divergences.be  édition du 15.11.07 : musique





More information about the NumPy-Discussion mailing list