title: Slicing a Python OrderedDict
body: <p>In my code I frequently need to take a subset range of keys+values from a Python <code>OrderedDict</code> (from <a href="https://docs.python.org/2/library/collections.html" rel="noreferrer"><code>collections</code></a> package). Slicing doesn't work (throws <code>TypeError: unhashable type</code>) and the alternative, iterating, is cumbersome:</p>
  
  <pre><code>from collections import OrderedDict
  
  o = OrderedDict([('a', 1), ('b', 2), ('c', 3), ('d', 4)])
  
  # want to do:
  # x = o[1:3]
  # need to do:
  x = OrderedDict()
  for idx, key in enumerate(o):
      if 1 &lt;= idx &lt; 3:
          x[key] = o[key]
  </code></pre>
  
  <p>Is there a better way to get this done?</p>