no-clobber dicts?

r rt8396 at
Tue Aug 4 01:39:25 CEST 2009

On Aug 3, 5:00 pm, Chris Rebert <c... at> wrote:
> On Mon, Aug 3, 2009 at 2:47 PM, r<rt8... at> wrote:
> > Not sure if something like this already exists, but it would be
> > trivial to implement by overriding dict.__setitem__()
> That is, if you don't care about .update() not preserving the
> invariant. Otherwise, one will need to look at the UserDict module.
> Cheers,
> Chris
> --

Good catch Chris. However since the OP said this was for testing
purposes,  i just *assumed* he would be smart enough *not* to call
update() on the dict at hand ;-). But sometimes i need to be protected
from myself too -- at least thats what my therapist keeps telling
me :-)

More information about the Python-list mailing list