title: Converting YAML file to python dict
body: <p>I am having the following problem of mapping documents within a YAML file to a <code>dict</code> and properly mapping them.</p>
  
  <p>I have the following YAML file, which represents a server (<code>db.yml</code>):</p>
  
  <pre><code>instanceId: i-aaaaaaaa
       environment:us-east
       serverId:someServer
       awsHostname:ip-someip
       serverName:somewebsite.com
       ipAddr:192.168.0.1
       roles:[webserver,php]
  </code></pre>
  
  <p>I load this YAML file, which I can do without any problems, I think I understand that.</p>
  
  <pre><code>instanceId = getInstanceId()
  stream = file('db.yml', 'r')
  dict = yaml.load_all(stream)
  
  for key in dict:
      if key in dict == "instanceId":
          print key, dict[key]
  </code></pre>
  
  <p>I'd like the logic to work like the following:</p>
  
  <ul>
  <li>load yaml, map to dict</li>
  <li>look in every dict in the document, if the <code>instanceId</code> matches that which was set by <code>getInstanceId()</code>, then print out all of the keys and values for that document.</li>
  </ul>
  
  <p>If I look at the map data structure from the command line, I get:</p>
  
  <pre><code>{'instanceId': 'i-aaaaaaaa environment:us-east serverId:someServer awsHostname:ip-someip serverName:someserver ipAddr:192.168.0.1 roles:[webserver,php]'}
  </code></pre>
  
  <p>I think I might be creating the data structure for the YAML file improperly, and on matching the contents on the <code>dict</code>, I am a bit lost.</p>
  
  <p>Side note: I cannot load all of the documents in this file using <code>yaml.load()</code>, I tried <code>yaml.load_all()</code>, which seems to work but my main issue still exists.</p>