title: Get array of a specific attribute of all objects from an array of objects
body: <p>I have an array containing a set of an object with many attributes. I want to get the values of specific attributes as a list in a simple way.</p>
  
  <p>I do know that I can make a list of each attribute and save them into individual lists as follows. </p>
  
  <pre class="lang-py prettyprint-override"><code>attr = (o.attr for o in objarray)
  </code></pre>
  
  <p>But as there are a lot of attributes and these need to analyzed using plots, distributions etc. this is not an efficient way.</p>
  
  <p>In my case, I am analyzing an array of 'Structure' objects which has attributes like lattice constants, position of atoms etc. And the object has functions to get distance, angles, etc. which when we give the index of atoms will return the corresponding values. What I want is to get a list of values (which may be an attribute like lattice constant or an output of a function of the object like distance between two atoms) each corresponding to each of the structures in the array. Making an individual list for each of the values needed (as mentioned above) is less efficient as a lot of such lists may need to be made and the values needed may differ depending on the purpose.</p>
  
  <p>What I need is to get a list of values by something in the manner of:</p>
  
  <pre class="lang-py prettyprint-override"><code>objarray[a:b].attr
  </code></pre>
  
  <p>which can be used easily for plotting and other functions. But this doesn't work and gives an error:</p>
  
  <pre class="lang-py prettyprint-override"><code>[ERROR] 'list' object has no attribute 'attr'
  </code></pre>
  
  <p><strong>Alternately</strong>, is there a way to make an array of objects which treats objects in the above mentioned way.</p>