title: Python accessing to wrong key
body: <p>I'm using a <code>dictionary</code> as an alternative to an <code>if/elif</code> structure that looks like this:</p>
  
  <pre><code>newValue = {
      'int': param.value + (random.choice((-1, 1)) * 
          random.randint(1, param.maxChange)),
      'float': param.value + random.uniform(-param.maxChange,
              param.maxChange),
      'bool': not param.value
  }[param.dataType]
  </code></pre>
  
  <p>but when <code>param.dataType</code> is <code>'float'</code>, it access to the <code>'int'</code> value. If I use the <code>if/elif</code> structure, it works as expected.</p>
  
  <pre><code>if param.dataType == 'int':
      newValue = param.value + (random.choice((-1, 1)) * 
          random.randint(1, param.maxChange))
  
  elif param.dataType == 'float':
      newValue = param.value + random.uniform(-param.maxChange,
          param.maxChange)
  
  elif param.dataType == 'bool':
      newValue = not param.value
  </code></pre>
  
  <p>What could be wrong with the dict form? I'm using Python 2.7</p>
  
  <p><strong><em>Edit:</em></strong> It wasn't that it was accessing to the wrong key. I was getting an exception belonging to the 'int' block of code, so I thought it was trying to assign the value from 'int' to newValue.</p>