Hello, finally I've solved it using a "combinatorics" library which allows to do this kind of things.
Here, here is an example: http://automatthias.wordpress.com/2007/04/28/cartesian-product-of-multiple-sets/ Thanks for your suggestions. Regards, Alfons. Carl Banks wrote: > On Sep 22, 3:08 am, Alfons Nonell-Canals <alfons.non...@upf.edu> > wrote: > >> Hello, >> I have different sets/dictionaries/lists (whatever you want because I >> can convert them easily) and I would like to combine them. I don't want >> a consensus and something like it. I'd need to combine all elements of >> the first one with the all elements of the second one and third,... the >> numbers of dictionaries/sets/lists is variable as the number of elements >> for each one. >> >> For example, i have the following sets and I would like to obtain all >> possible combinations... >> >> ['I', 'O', 'N', 'P', 'S', 'C'] >> ['I', 'O', 'N', 'P', 'S', 'C'] >> ['I', 'O', 'N', 'P', 'S', 'C'] >> ['I', 'N', 'P', 'S', 'C'] >> ['I', 'N', 'P', 'S', 'C'] >> ['F', 'I', 'L', 'O', 'N', 'P', 'S', 'R', 'C'] >> ['I', 'O', 'N', 'P', 'S', 'C'] >> ['I', 'O', 'N', 'P', 'S', 'C'] >> ['F', 'I', 'L', 'O', 'N', 'P', 'S', 'R', 'C'] >> > > This is the input. What do you want the output to look like given > this input? > > I can't really tell exactly what you mean by "all combinations", there > are different ways to combine sequences, and it doesn't sound like you > mean the formal mathematical definition of "combination". > > My best guess is that you want something like this. > > def all_union(seqs): > s = set() > for seq in seqs: > s.update(seq) > return s > > > Carl Banks > -- ------------ Alfons Nonell-Canals, PhD Chemogenomics Lab Research Group on Biomedical Informatics (GRIB) - IMIM/UPF Barcelona Biomedical Research Park (PRBB) C/ Doctor Aiguader, 88 - 08003 Barcelona alfons.non...@upf.edu - http://cgl.imim.es Tel. +34933160528 http://alfons.elmeuportal.cat http://www.selenocisteina.info -- http://mail.python.org/mailman/listinfo/python-list