def merge_dictionaries(D1,D2): """merge_dictionaries(D1,D2) Merge two disjoint dictionaries The first argument D1 is modified to hold the result of the merger. If dictionaries are not disjoint an exception is raised """ import types for k in D2.keys(): val = D2[k] if not D1.has_key(k): D1[k] = val else: print 'Dictionaries not disjoint' raise Exception return D1