python list comprehensions question
<p>So I have an array of the following form:</p>

<pre><code>[(1, u'first_type', u'data_gid_1'), 
 (2, u'first_type', u'data_gid_2'), 
 (3, u'first_type', u'data_gid_3'), 
 (4, u'first_type', u'data_gid_4')]
</code></pre>

<p>Now I want to extract the first and the last element of each inside list into separate lists. So if I do:</p>

<pre><code>&gt;&gt;&gt; ids = [dat[0] for dat in all_data]
&gt;&gt;&gt; gds = [dat[2] for dat in all_data]
</code></pre>

<p>This works as I expect it to. However I was trying to merge these two into one call, something like:</p>

<pre><code> (ids, gds) = [(dat[0], dat[2]) for dat in all_data]
</code></pre>

<p>This however fails with an:
     <code>ValueError: too many values to unpack</code></p>

<p>So could anyone explain why this is happening and if what I am trying to do is even possible.</p>

<p>Regards,
Bogdan    </p>
