my code this:
for register in registerlist1: parentlist1.append(register._getparent().getname()) classlist1.append(register.getaddress()) classlist1.append(register.getdirection()) classlist1.append(parentlist1) classlist1.append(classlist1) print classlist1 parentlist1=[] classlist1=[] classlist1=[]
output:
[['b'], [1000, 'in']] [['c'], [1001, 'out']]
i want store each output in array this:
classlist1[0] =[['b'], [1000, 'in']] classlist1[1] =[['c'], [1001, 'out']]
note: registerlist1
contains instance gives me address , direction.
can me here??
you should simplify code , build lists directly, , build outer list appending:
class_list = [] register in registerlist1: class_list.append([ [register._getparent().getname()], [register.getaddress()), register.getdirection() ]) print class_list
the above code builds nested lists in 1 go.
Comments
Post a Comment