How to define multidimensional dictionary with default value in python?
<p>I would like to modify next dict definition:</p>

<pre><code>class Vividict(dict):
      def __missing__(self, key):
           value = self[key] = type(self)()
           return value
</code></pre>

<p>To be able to use it in next way:</p>

<pre><code>totals[year][month] += amount    
</code></pre>

<p>At the end I have used Counter with tuple as a key.</p>

python dictionary autovivification