I have a big list of lists (of lists of lists…,) which I will call A.
A = [b1, b2, b3, b4, b5, …] where bn is a collection of values of properties at frame n. b1 is of the same format as b2, and so on.
I would like to be able to extract A[:][c][d][e][f]…, that is, the list of values in A[i][c][d][e][f]… for every i in range(len(A)).
I currently have a procedure demonstrated here:
import bpy
z = [0,1]
b = [z,[2,3]]
q = [b,b,b]
A = [q,q,q,q]
print(A,'
')
j = 1
k = 0
l = 1
n = [j,k,l]
def Extractor(A,n):
a = []
for i in range(len(A)):
if type(A[i]) == list:
if type(A[i][n[0]]) == list:
if type(A[i][n[0]][n[1]]) == list:
a.append(A[i][n[0]][n[1]][n[2]])
else:
a.append(A[i][n[0]][n[1]])
else:
a.append(A[i][n[0]])
else:
a.append(A[i])
return a;
a = Extractor(A,n)
print(a)
but as you see, there is a limit to how deep I can go with this method. Arbitrarily deep, so long as I write the function long enough, but is there a better way to do this? And what if I want to find A[b][:][d][e][f]…? Is there a more flexible way to extract elements from a known place in a list of lists?