Getting data from Google Maps python object
<p>I've gathered some data from Google Maps API but I'm stuck on getting out the LAT/LNG.</p>

<p>Creating object:</p>

<pre><code>loc = self.google_maps.geocode(location)
</code></pre>

<p>I cannot traverse down this object:</p>

<pre><code>pprint(loc)
</code></pre>

<p><a href="http://i.stack.imgur.com/J7CVI.png" rel="nofollow"><img src="http://i.stack.imgur.com/J7CVI.png" alt="enter image description here"></a></p>

<p>I've tried:</p>

<pre><code>loc.address_components
loc['address_components']
loc-&gt;address_components

loc.geometry
loc['geometry']
</code></pre>

<p>etc which all fail. This feels like such a simple question but I don't know they all fail to work</p>

<p>You should try:</p>

<pre><code>loc[0]['address_components']
#   ^ index the list
</code></pre>

<p>That's because your dict is contained in a list.</p>

<p>The same applies to other dictionaries that deeply nested:</p>

<pre><code>loc[0]['address_components'][0]['long_name'] 
# or loc[0]['address_components'][1]['long_name'] for second nested dict
</code></pre>

python