How can I get Python to automatically create missing key/value pairs in a dictionary?
<p>I'm creating a dictionary structure that is several levels deep.  I'm trying to do something like the following:</p>

<pre><code>dict = {}
dict['a']['b'] = True
</code></pre>

<p>At the moment the above fails because key 'a' does not exist.  At the moment I have to check at every level of nesting and manually insert an empty dictionary.  Is there some type of syntactic sugar to be able to do something like the above can produce:</p>

<pre><code>{'a': {'b': True}}
</code></pre>

<p>Without having to create an empty dictionary at each level of nesting?</p>
