Last change
on this file since 81 was
18,
checked in by ole, 20 years ago
|
Added old pytools module from CVS
|
File size:
509 bytes
|
Line | |
---|
1 | |
---|
2 | def merge_dictionaries(D1,D2): |
---|
3 | """merge_dictionaries(D1,D2) |
---|
4 | |
---|
5 | Merge two disjoint dictionaries |
---|
6 | The first argument D1 is modified to hold the result of the merger. |
---|
7 | If dictionaries are not disjoint an exception is raised |
---|
8 | """ |
---|
9 | import types |
---|
10 | |
---|
11 | for k in D2.keys(): |
---|
12 | val = D2[k] |
---|
13 | if not D1.has_key(k): |
---|
14 | D1[k] = val |
---|
15 | else: |
---|
16 | print 'Dictionaries not disjoint' |
---|
17 | raise Exception |
---|
18 | |
---|
19 | return D1 |
---|
20 | |
---|
Note: See
TracBrowser
for help on using the repository browser.