retrieve item from nested list given index tuple

Alan G Isaac alan.isaac at gmail.com
Fri Aug 14 14:02:58 EDT 2009


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



More information about the Python-list mailing list