title: slicing subset of list in a dict: how to turn index to integer?
body: <p>From user input you can get an expression, which indicates what elements you want from a dict:</p>
  <pre><code>key[0]
  key[0:2]
  key[-1]
  </code></pre>
  <p><code>key</code> is the key from the dict. The values in the dict are stored as a list. Therefore if the user puts <code>key[0]</code>, the first element from the values list should be returned.</p>
  <p>Now, I got this to work by using:</p>
  <pre><code>input = ['key[0]']
  key = input[0].split('[')[0]
  index = self[0].split('[')[1].replace(']', '')
  return dict[key][int(index)]
  </code></pre>
  <p>A little ugly, I gotta admit, but it works for well normal integers. The problem is when trying to get a subset like <code>key[0:2]</code>, since obviously <code>0:2</code> is not an integer.
  How can I get this to work anyways? Is there maybe an even more efficient way to do this?</p>
  <p>PS: I tried it with <code>eval(index)</code> as well, but same problem...</p>