title: Mapping nested dictionaries in python
body: <p>I'm transforming fields from an XML document so I can load into a normal relational DB. I've transformed the XML document to a bunch of nested dictionaries. Some of the values I wish to extract are in nested dictionaries, so I need to flatten it first. </p>
  
  <p>Easy enough, but I'd like to create a mapping that lets me specify upfront what to extract.</p>
  
  <p><em>Example</em></p>
  
  <pre><code>input_dict = {
  'authors': [{'name': u'Google, Inc.'}],
  'islink': False,
  }
  
  mapping = ['islink',&lt;???&gt;]
  </code></pre>
  
  <p><em>Desired output</em></p>
  
  <pre><code>In: tuple(input_dict[key] for key in mapping)
  Out: (False, 'Google, Inc.')
  </code></pre>
  
  <p>This obviously doesn't work: </p>
  
  <pre><code>In: [input_dict[key] for key in ['islink',['authors'][0]['name']]]
  Out: TypeError: string indices must be integers, not str
  </code></pre>