Re: retrieve item from nested list given index tuple

2009-08-14 Thread Colin J. Williams
Dave Angel wrote: Colin J. Williams wrote: Steven D'Aprano wrote: On Fri, 14 Aug 2009 15:54:54 +, Alan G Isaac wrote: `lst` is a nested list `tpl` is the indexes for an item in the list What is the nice way to retrieve the item? (Speedy access is nice.) Assuming you want to do thi

Re: retrieve item from nested list given index tuple

2009-08-14 Thread Dave Angel
Colin J. Williams wrote: Steven D'Aprano wrote: On Fri, 14 Aug 2009 15:54:54 +, Alan G Isaac wrote: `lst` is a nested list `tpl` is the indexes for an item in the list What is the nice way to retrieve the item? (Speedy access is nice.) Assuming you want to do this frequently, write a

Re: retrieve item from nested list given index tuple

2009-08-14 Thread Alan G Isaac
On 8/14/2009 1:09 PM Steven D'Aprano apparently wrote: > Try this instead: > from operator import getitem reduce(getitem, (2, 1, 0), lst) > 'aaa' reduce(getitem, (2, 1, 0, 0), lst) > 'a' > > operator.getitem is less ugly too. Yes, that's better. Thanks, Alan -- http://mail.pytho

Re: retrieve item from nested list given index tuple

2009-08-14 Thread Colin J. Williams
Steven D'Aprano wrote: On Fri, 14 Aug 2009 15:54:54 +, Alan G Isaac wrote: `lst` is a nested list `tpl` is the indexes for an item in the list What is the nice way to retrieve the item? (Speedy access is nice.) Assuming you want to do this frequently, write a helper function, then us

Re: retrieve item from nested list given index tuple

2009-08-14 Thread Steven D'Aprano
On Fri, 14 Aug 2009 15:54:54 +, Alan G Isaac wrote: > `lst` is a nested list > > `tpl` is the indexes for an item in the list > What is the nice way to retrieve the item? (Speedy access is nice.) Assuming you want to do this frequently, write a helper function, then use it: # Untested def