title: How to make a nested dictionary and dynamically append data
body: <p>I have a loop giving me three variables</p>
  
  <pre><code>matteGroup
  matteName
  object
  </code></pre>
  
  <p>I would like to make a nested dicionary holding all the data like:</p>
  
  <pre><code>dictionary{matteGroup: {matteName: obj1, obj2, ob3} }
  </code></pre>
  
  <p>I am checking the objects one by one so I would like to create the <code>matteGroup</code> if it doesn't exist, create the <code>matteName</code> if it doesn't exixst and then create or append the name of the object.
  I tryed a lot of solution like normal dictionaries, defaultdict and some custom classes I found on the net, but I haven't been able to do it properly. I have a nice nesting I am not able to append, or vice versa.</p>
  
  <p>This is the loop</p>
  
  <pre><code>    dizGroup = {}
      dizName = {}
  
      for obj in mc.ls(type='transform'):
          if mc.objExists(obj + ('.matteGroup')):
              matteGroup = mc.getAttr(obj + ('.matteGroup'))
              matteName = mc.getAttr(obj + ('.matteName'))
  
              if matteGroup not in dizGroup:
                  dizGroup[matteGroup] = list()
              dizGroup[matteGroup].append(matteName)
  
              if matteName not in dizName:
                  dizName[matteName] = list()
              dizName[matteName].append(obj)
  </code></pre>
  
  <p>with this I get the two dictionaries separately, but is not so useful!
  Any hint?</p>
  
  <p>Thanks</p>