title: Finding average of variable in objects python
body: <p>How can I iterate over a group of objects to find their mean in the most efficent way? This uses just one loop (except perhaps loops in Numpy) but I was wondering whether there was a better way. At the moment, I am doing this:</p>
  
  <pre><code>scores = []
  ratings= []
  negative_scores = []
  positive_scores = []
  
  for t in text_collection:
   scores.append(t.score)
   ratings.append(t.rating)
   if t.score &lt; 0:
      negative_scores.append(t.score)
   elif t.score &gt; 0:
      positive_scores.append(t.score)
  
  print "average score:", numpy.mean(scores)
  print "average rating:", numpy.mean(ratings)
  print "average negative score:", numpy.mean(negative_scores)
  print "average positive score:", numpy.mean(positive_scores)
  </code></pre>
  
  <p>Is there a better way of doing this?</p>