title: Is it possible to slice keys in h5py using python 3, without forming a list?
body: <p>I am using h5py to read in data from an HDF5 file, and have found that code which worked using Python 2 does not work using Python 3.  The file is formatted such that 2D frames of data are present as distinct datasets, which I want to read into a 3D array.  The file structure looks like this:</p>
  
  <pre><code>file.h5
   |- groupname (group)
       |- frame1 (dataset)
       |- frame2 (dataset)
     ...
  </code></pre>
  
  <p>To read the frames into a 3D array, I have to access the first dataset to get its shape and type information.  Because I don't actually know the <em>exact</em> name for each frame, the code I had been using to access the first frame looked like this:</p>
  
  <pre><code>import h5py
  
  fid = h5py.File('file.h5', 'r')
  datagroup = fid['groupname']
  dataset0 = datagroup[datagroup.keys()[0]]
  </code></pre>
  
  <p>However, the <a href="http://docs.h5py.org/en/latest/high/group.html" rel="nofollow">documentation</a> for h5py says</p>
  
  <blockquote>
    <p>"When using h5py from Python 3, the keys(), values() and items() methods will return view-like objects instead of lists."</p>
  </blockquote>
  
  <p>The view objects support iteration but not slicing.  So to avoid an error I had to change that line to the following:</p>
  
  <pre><code>dataset0 = datagroup[ [k for k in datagroup.keys()][0] ]
  </code></pre>
  
  <p>which artificially constructs a temporary list and then grabs its first element.  To me this looks awful.  Is there a better way to do this?</p>