title: How to store 'yield' generator result in a list in Python 2.7?
body: <p>I have a code like this:</p>
  
  <pre><code>import math    
  nList = [[[0, 0, 0], [3, 2, 1]],\
       [[]],\
       [[1, 1, 12]],\
       [[0, 0, 0], [30000, 40, 3010], [32000, 40500, 7520], [0, 0, 10520]],\
       [[15340, 0, 0], [104300, 0, 3630], [434000, 4434000, 63460]]]
  
  def calculate_length(x1, y1, x2, y2):
      return math.sqrt((x1-x2)**2 + (y1 - y2)**2)
  
  def calculate_time (t1,t2):
      return abs(t1-t2)
  
  def lengths(trace):
      previous_x, previous_y = 0, 0
      for index, point in enumerate(trace):
          if point:
              x, y, t = point
              if index &gt; 0:
                  yield calculate_length(x, y, previous_x, previous_y)
              previous_x, previous_y = x, y
  </code></pre>
  
  <p>How would I store the <code>yield</code> results of <code>calculate_length(x, y, previous_x, previous_y)</code> in a list? </p>
  
  <p><code>nList</code> has <code>traces</code> in them with each <code>trace</code> having <code>points</code> with 3 elements, <code>[x,y,t]</code>. I need to store the lengths of each trace so that the output generated is:</p>
  
  <pre><code>all_lengths_list=[[3]],[[]],[[]],[[30000.02667],[40509.40138],[51616.37337]],[[88960],[4446240]]]
  </code></pre>