title: getting a sample from a dictionary
body: <p>I want to get a sample from a dictionary which holds image data. <code>Code 1</code> shows a simple example:</p>
  <p><strong>Code 1:</strong></p>
  <pre><code>import numpy as np
  
  a = dict(data_key_1=np.random.random((512, 512, 3)), 
           data_key_2=np.random.random((512, 512, 3)), 
           data_key_3=np.random.random((512, 512, 3)), 
           data_key_4=np.random.random((512, 512, 3)),
           data_key_5=np.random.random((512, 512, 3)),
           data_key_6=np.random.random((512, 512, 3)),
           data_key_7=np.random.random((512, 512, 3)),
           data_key_8=np.random.random((512, 512, 3)),
           data_key_9=np.random.random((512, 512, 3)),
           data_key_10=np.random.random((512, 512, 3))
          )
  sample_keys = ['data_key_2', 'data_key_1', 'data_key_7', 'data_key_4']
  </code></pre>
  <p><strong>Desired Output:</strong></p>
  <p>The output should contain the images at the keys specified by the items in <code>sample_keys</code> list, stored in the <code>a</code> dictionary.</p>
  <p><strong>What I've tried:</strong></p>
  <p>I thought that it could be done as with <code>nympy</code>'s fancy indexing as shown in <code>Code 2</code>, but got an <code>Error 1</code>.</p>
  <p><strong>Code 2:</strong></p>
  <pre><code>a[sample_keys]
  </code></pre>
  <p><strong>Error 1</strong></p>
  <pre><code>---------------------------------------------------------------------------
  TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-317-bf897da15ff6&gt; in &lt;module&gt;
  ----&gt; 1 a[sample_keys]
  
  TypeError: unhashable type: 'list'
  </code></pre>
  <p><strong>Naive solution:</strong></p>
  <p>I realize i can do it with a for loop like in <code>Code 3</code>, but I'm interested in a more &quot;elegant&quot; (i.e. without loops, and as less lines of code as possible) solution.</p>
  <p><strong>Code 3:</strong></p>
  <pre><code>X = []
  
  for image_id in sample_keys:
      X.append(a[image_id])
  </code></pre>
  <p>I'd appreciate any help for getting the desired output. Thanks in advance.</p>