I have list of assembly class instances. The total number of assemblies in the list can change.
ASM_list = [ASM1,ASM2,ASM3...etc]
each assembly has a list of parts (I have filtered the assemblies to all have the same parts)
ASM1.parts = ['hood','fender','door']
ASM2.parts = ['hood','fender','door']
each part has properties
ASM1.parts[0].color = green
ASM2.parts[0].color = blue
I would like to print out part properties for each assembly. Example output:
part, ASM1, ASM2, ASM3
hood, green, blue, red
fender, black, red, yellow
door, yellow, green, orange
I'm having trouble using zip or map to do this.
An example of what I'm trying below.
parts_list = []
for ASM in ASM_list:
parts_list.append([p.color for p in ASM.parts])
print zip(*parts_list)
The "Python cookbook" and several other stack overflow posts show how to iterate through multiple list at the same time, the problem I have is that the number of assemblies changes so I can't write:
for a,b,c in ASM_lists:
a.part.color, b.part.color, c.part.color
Thanks!