Re: Generating multiple lists from one list

2006-07-06 Thread Gerard Flanagan
Girish Sahani wrote: > hello ppl, > > Consider a list like ['a.1','b.3','b.4','c.2']. Here 'a','b','c' are > objects and 1,3,4,2 are their instance ids and they are unique e.g. a.1 > and b.1 cannot exist together. From this list i want to generate > multiple lists such that each list must have o

Re: Generating multiple lists from one list

2006-07-06 Thread Amit Khemka
> On 7/6/06, Girish Sahani <[EMAIL PROTECTED]> wrote: > Thus, for the above list, my output should be: > [['a.1','b.3','c.2'],['a.1','b.4','c.2']] > Another example: Let l = ['a.1','b.3','b.4','c.2','c.6','d.3']. Then > output should be [['a.1','b.3','c.2','d.3'],['a.1','b.3','c.6','d.3'], > ['

Generating multiple lists from one list

2006-07-05 Thread Girish Sahani
hello ppl, Consider a list like ['a.1','b.3','b.4','c.2']. Here 'a','b','c' are objects and 1,3,4,2 are their instance ids and they are unique e.g. a.1 and b.1 cannot exist together. From this list i want to generate multiple lists such that each list must have one and only one instance of every

Re: Generating multiple lists from one list

2006-07-05 Thread Anand
> p_code = '' > for i,k in enumerate(ks): > p_code += i*' ' + "for item%s in elts['%s']:\n" %(i,k) > p_code += len(ks)*' '+'print ['+','.join([ "item%s" %i > for i,k in enumerate(ks) ])+']' > > # print the code > print p_code > > >for item0 in elts['a']: > > for item1 in elts['b']: > > for

Re: Generating multiple lists from one list

2006-07-05 Thread Pierre Quentel
# first step : build a dictionary mapping the objects # to all possible ids alist = ['a.1','b.3','b.4','c.2','c.6','d.3'] elts = {} for item in alist: obj=item.split('.')[0] if elts.has_key(obj): elts[obj].append(item) else: elts[obj] = [item] # then build the Python c

Generating multiple lists from one list

2006-07-05 Thread Girish Sahani
hello ppl, Consider a list like ['a.1','b.3','b.4','c.2']. Here 'a','b','c' are objects and 1,3,4,2 are their instance ids and they are unique e.g. a.1 and b.1 cannot exist together. From this list i want to generate multiple lists such that each list must have one and only one instance of every