On Fri, Apr 13, 2012 at 5:11 AM, John O'Hagan <resea...@johnohagan.com> wrote:
> I think you also have to check if a[k] is a dict before making the recursive
> call, else for example dmerge({'a': 1}, {'a': {'b': 1}}) fails with a
> TypeError. In that case the third line above should read:
>
>    if k in a and isinstance(a[k], dict) and isinstance(v, dict):

Okay, but then what do you do in that case?  You can't merge a dict
into an int.  Unless the OP has some specific type conflict semantics
in mind, the above *should* raise a TypeError, because in the above
you have passed in two structures that are incompatible for merging.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to