I have the following lists:
path='/my/path/'
l1=[2,0,1]
l2=[['a.txt','b.txt','c.txt'],['d.txt','f.txt','g.txt'],['h.txt','i.txt','j.txt']]
and I wrote a list comprehension to add the full path:
[os.path.join(path, 'list%d'%l1_index, l2_value) for l1_index in l1 for l2_value in l2[l1_index]]
but lost the original nesting.
Here's what I'd like to get:
[ ['/my/path/list2/h.txt','/my/path/list2/i.txt','/my/path/list2/j.txt'], ['/my/path/list0/a.txt','/my/path/list0/b.txt','/my/path/list0/c.txt'], ['/my/path/list1/d.txt','/my/path/list1/f.txt','/my/path/list1/g.txt'] ]