title: insert or update keys in a python dictionary
body: <p>I have a python dictionary <code>dict1</code> with more than 20,000 keys and I want to <code>update</code> it with another dictionary <code>dict2</code>. The dictionaries look like this:</p>
  
  <pre><code>dict1
    key11=&gt;[value11]
    key12=&gt;[value12]
    ...
    ...
    keyxyz=&gt;[value1x]      //common key
    ...... so on
  
  dict2
    key21=&gt;[value21]
    key22=&gt;[value22]
    ...
    ...
    keyxyz=&gt;[value2x]      // common key
    ........ so on
  </code></pre>
  
  <p>If I use</p>
  
  <pre><code>dict1.update(dict2)
  </code></pre>
  
  <p>then the keys of <code>dict1</code> which are similar to keys of <code>dict2</code> will have their values overwritten by values of <code>dict2</code>. What I want is if a key is already present in dict1 then the value of that key in dict2 should be appended to value of dict1. So</p>
  
  <pre><code>dict1.conditionalUpdate(dict2)
  </code></pre>
  
  <p>should result in </p>
  
  <pre><code>dict1
    key11=&gt;[value11]
    key12=&gt;[value12]
    key21=&gt;[value21]
    key22=&gt;[value22]
    ...
    ...
    keyxyz=&gt;[value1x,value2x]
  </code></pre>
  
  <p>A naive method would be iterating over keys of <code>dict2</code> for each key of <code>dict1</code> and insert or update keys. Is there a better method? Does python support a built in data structure that supports this kind of functionality?</p>