title: String formatting [str.format()] with a dictionary key which is a str() of a number
body: <p>Python neophyte here. I was wondering if someone could help with the <code>KeyError</code> I am getting when using a dictionary for string interpolation in <a href="http://docs.python.org/library/stdtypes.html#str.format" rel="noreferrer"><code>str.format</code></a>.</p>
  
  <pre><code>dictionary = {'key1': 'val1', '1': 'val2'}
  
  string1 = 'Interpolating {0[key1]}'.format(dictionary)
  print string1
  </code></pre>
  
  <p>The above works fine and yields:</p>
  
  <pre><code>Interpolating val1
  </code></pre>
  
  <p>However doing the following:</p>
  
  <pre><code>dictionary = {'key1': 'val1', '1': 'val2'}
  
  string2 = 'Interpolating {0[1]}'.format(dictionary)
  print string2
  </code></pre>
  
  <p>results in: </p>
  
  <pre><code>Traceback (most recent call last):
    File "test.py", line 3, in &lt;module&gt;
      string2 = 'Interpolating {0[1]}'.format(dictionary)
  KeyError: 1L
  </code></pre>
  
  <p><del>So the problem seems to be in the interpretation of the numeric key as a list index, IMHO.</del> Is there any way to work around this? <del>(i.e. convey that this is instead a dictionary key)</del></p>
  
  <p>TIA and apologies if this question has been asked before(couldn't find anything relevant with my search-fu). </p>
  
  <p>Edit 1: The key is not numeric as was erroneously noted, earlier. Instead it is a string representation of a number - as was pointed out by <a href="https://stackoverflow.com/a/11130837/391113">BrenBarn</a>.</p>