Array construction from object members



Hi everyone,

I am doing several operations on lists and I am wondering if python has
anything built in to get every member of several objects that are in an
array, for example, if i have a class like the following:

class myClass:
a = 0.0

And lets say I populate the "a" element in an array of objects of
myClass. If I want to retrieve all items in this and perhaps give it
to a mean function, I would need to make a loop now:

mySimpleArray = []
for i in range(0,len(myArray)):
mySimpleArray.append(myArray[i].a)

There must be some more efficient way to do this, can someone point me
to the right direction so that I can review some documentation and get
things a little more efficient?

thanks!

.



Relevant Pages

  • Re: Array construction from object members
    ... > I am doing several operations on lists and I am wondering if python has ... > anything built in to get every member of several objects that are in an ... > array, for example, if i have a class like the following: ...
    (comp.lang.python)
  • Re: Best Coding Practice
    ... I needed to add an array class member to an object. ... OO standpoint to make a FreeProduct class which extends the Product ... Cost is an attribute, and different values for attributes should not determine new products. ...
    (comp.lang.php)
  • Re: Best Coding Practice
    ... I needed to add an array class member to an object. ... the logic was the same between the two arrays aside from the price, ... and the child classes the specific elements. ...
    (comp.lang.php)
  • calloc problem
    ... I am trying to dynamically allocate memory to be used as an array. ... The array is pointed to by the 'vert' member of the structure 'grid'. ... I wish for this array to be a 2 dimensional array of the struct ...
    (comp.lang.c)
  • Re: Best Coding Practice
    ... I needed to add an array class member to an object. ... wouldn't feel entirely comfortable suddenly making it a child class of ... Product with a cost of 0. ...
    (comp.lang.php)