Re: replace deepest level of nested list

2006-09-05 Thread Michael Spencer
David Isaac wrote: > Thanks to both Roberto and George. > I had considered the recursive solution > but was worried about its efficiency. > I had not seen how to implement the numpy > solution, which looks pretty nice. > > Thanks! > Alan > > You could also use pyarray, which mimics numpy's index

Re: replace deepest level of nested list

2006-09-04 Thread David Isaac
Thanks to both Roberto and George. I had considered the recursive solution but was worried about its efficiency. I had not seen how to implement the numpy solution, which looks pretty nice. Thanks! Alan -- http://mail.python.org/mailman/listinfo/python-list

Re: replace deepest level of nested list

2006-09-04 Thread Roberto Bonvallet
David Isaac wrote: > I have a list of lists, N+1 deep. > Like this (for N=2): > [[['r00','g00','b00'],['r01','g01','b01']],[['r10','g10','b10'],['r11','g11' > ,'b11']]] > > I want to efficiently produce the same structure > except that the utlimate lists are replaced by a chosen (by index) item. >

Re: replace deepest level of nested list

2006-09-04 Thread George Sakkis
David Isaac wrote: > I have a list of lists, N+1 deep. > Like this (for N=2): > [[['r00','g00','b00'],['r01','g01','b01']],[['r10','g10','b10'],['r11','g11' > ,'b11']]] > > I want to efficiently produce the same structure > except that the utlimate lists are replaced by a chosen (by index) item. >

replace deepest level of nested list

2006-09-04 Thread David Isaac
I have a list of lists, N+1 deep. Like this (for N=2): [[['r00','g00','b00'],['r01','g01','b01']],[['r10','g10','b10'],['r11','g11' ,'b11']]] I want to efficiently produce the same structure except that the utlimate lists are replaced by a chosen (by index) item. E.g., [['r00','r01'],['r10','r11']