Hello,

I have an object, and this object has attributes. These attributes are 
objects in their own right, and each attribute also have its own attributes.

So I loop over the "top" object, and for each attribute encountered, I 
want to put in a list two of the attributes of this attribute. Hope it 
makes sense.

Right now, here is what I'm doing:



aList = [ [], [] ]


# Iterate attributes of the top object          
for oAttribute in oObj.attributes:
        
        # Append to list 0 the attribute "type" of the current attribute
        aList[0].append( str(oAttribute.type) )

        # Append to list 1 the attribute "name" of the current attribute
        aList[1].append( str(oAttribute.name) )




Instead of having two separate lists and a for loop, I'd like to perform 
a list comprehension that would do this all in one go, if this is doable.



Thanks
Bernard

_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to