python : merge dictionaries

25 Oct 2011

Here is the two simple ways to merge dictionaries in python.

  1. Using update method
    By using this method the second dictionary(new_adm) will be merged to the first one(default) and the update method will return None.

  2. Using dict constructor
    By using this method both first dictionary and second will be merged and stored in a third dictionary(resultant) and default and new_adm will remain unchanged.

If you particularly enjoy my work, I appreciate donations given with Gittip.