|
From: Matthew B. <mat...@gm...> - 2005-12-05 18:03:57
|
Hi,
> You can only update from a dictionary (b must be a dictionary or a
> ConfigObj).
Ah yes, sorry, I was comparing your method to my function, and forgot
that. Doh.
> Because all subsections are instances of Section - the new method *is*
> recursive (it uses Section.update).
Yes, of course - but the standard dictionary update isn't:
>>> a =3D {'one': 1, 'two': {'as_field': 3}}
>>> b =3D {b =3D {'two': {'bs_field': 4}}
>>> a.update(b)
>>> a
>>> {'two': {'bs_field': 4}, 'one': 1}
So, for example, with the current code
a.update(b)
could give a different answer from
c =3D a.copy() # which gives a dict
c.update(b)
- or more generally, if d was a dictionary with the same (dictionary)
contents as a, then d.update(b) will not necessarily be the same as
a.update(b).
How about renaming the method to .recursive_update or something?
Best,
Matthew
|