title: Python list comprehension not working for itertools.groupby decoding
body: <p>I am trying to decode the result of an <code>itertools.groupby</code> into a list of values.</p>
  
  <p>My source is : </p>
  
  <pre><code>x = [(1, 2), (2, 1), (6, 3), (6, 5), (1, 3)]
  </code></pre>
  
  <p>While the original method is to do it with a for statement like this: </p>
  
  <pre><code>keyfunc = itemgetter(0)
  groups = []
  uniquekeys = []
  data = sorted(x, key=keyfunc)
  for k, g in itertools.groupby(data, keyfunc):
      groups.append(list(g))      # Store group iterator as a list
      uniquekeys.append(k)
  </code></pre>
  
  <p>I opt for using list comprehension to make it in one line as:</p>
  
  <pre><code>[(k, list(g)) for k, g in list(itertools.groupby(x, keyfunc))]
  </code></pre>
  
  <p>The result of the first method is:</p>
  
  <pre><code>[1, 2, 6] #for uniquekeys
  [[(1, 2), (1, 3)], [(2, 1)], [(6, 3), (6, 5)]] #for groups
  </code></pre>
  
  <p>Which totally makes sense.</p>
  
  <p>The result of the second method is:</p>
  
  <pre><code>[(1, []), (2, []), (6, [(6, 5)])]
  </code></pre>
  
  <p>Where we can see the groups are either empty or holding single integers.</p>
  
  <p>Where did it go wrong?</p>