Douglas Garstang wrote: > On Mon, Aug 2, 2010 at 12:47 AM, Paul Rubin <no.em...@nospam.invalid> wrote:
>> If yes, then the following works for me: >> >> def merge(cluster, default): >> # destructively merge default into cluster >> for k,v in cluster.iteritems(): >> if k in default and type(v)==dict: >> assert type(default(k))==dict >> merge(v,default[k]) >> for k,v in default.iteritems(): >> if k not in cluster: >> cluster[k] = v >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > Hmmm, using that gives me: > > Traceback (most recent call last): > File "./test4.py", line 48, in ? > merge(cluster, default) > File "./test4.py", line 42, in merge > assert type(default(k))==dict > TypeError: 'dict' object is not callable > > where line 42 is 'assert type(default(k))==dict', and the inputs are: Not making an attempt to understand the code that you are about to use? default(k) should be default[k] Peter -- http://mail.python.org/mailman/listinfo/python-list