On Thu, 16 Aug 2012 19:18:18 +0200, Thomas Bach wrote: > Imagine you have two data sets: > > d1 = {'foo': None} > d2 = {'foo': 8} > > Where I would assume that d1 has "foo" not set. That's why I want this > whole "merge"-thing in the first place: to be able to extract the type > {'foo': None} from d1 and {'foo': int} from d2 and merge the two > together which should result in {'foo': int}.
That becomes trivial if you do the merge before converting to types: d3 = d1.copy() # the merged dict for key, value in d2.items(): if key in d1 and d1[key] is None: d3[key] = value # merge Now pass d3 to your recursive_type function. -- Steven -- http://mail.python.org/mailman/listinfo/python-list