question about filtering a dictionary using a list in python
<p>with the following dictionary and array:</p>

<pre>
a = { 'a':[1,2,3,4,5], 'b':[1,2,3], 'c':[1,2,3,4,5] }
b = ['a','c']
</pre>

<p>I would like to filter a into a new dictionary to only have the key-values in the array b so i end up with:</p>

<pre>
c = {'a': [1, 2, 3, 4, 5], 'c': [1, 2, 3, 4, 5]}
</pre>

<p>So.. the obvious way to do this for me was the following:</p>

<pre>
(1) dict(map( lambda x:(x,a[x]), b)) 
</pre>

<p>Searching for different ways to do it I also see this:</p>

<pre>
(2) dict( (x, a[x]) for x in b)
</pre>

<p>I don't fully have my head around (2) but before I dive too deep into what is going on is there an advantage to using (2) over (1)? Or better yet is there a better way to do this?</p>
