Check for dictionaries using isinstance(), not is

This commit is contained in:
ZyX 2014-07-12 12:02:14 +04:00
parent 7f94583324
commit ee71eac7b2
1 changed files with 1 additions and 1 deletions

View File

@ -18,7 +18,7 @@ def mergedicts(d1, d2):
'''Recursively merge two dictionaries. First dictionary is modified in-place.
'''
for k in d2:
if k in d1 and type(d1[k]) is dict and type(d2[k]) is dict:
if k in d1 and isinstance(d1[k], dict) and isinstance(d2[k], dict):
mergedicts(d1[k], d2[k])
elif d2[k] is REMOVE_THIS_KEY:
d1.pop(k, None)