How can I create a dict that sets a flag if it's been modified

Amit Khemka khemkaamit at
Thu Jan 12 10:29:10 CET 2006

Ideally, I would have made a wrapper to add/delete/modify/read from
the dictionay.

But other than this, one way i can think straight off is to "pickle"
the dict, and to see if the picked object is same as current object.


On 12 Jan 2006 01:15:38 -0800, sandravandale at
<sandravandale at> wrote:
> I can think of several messy ways of making a dict that sets a flag if
> it's been altered, but I have a hunch that experienced python
> programmers would probably have an easier (well maybe more Pythonic)
> way of doing this.
> It's important that I can read the contents of the dict without
> flagging it as modified, but I want it to set the flag the moment I add
> a new element or alter an existing one (the values in the dict are
> mutable), this is what makes it difficult. Because the values are
> mutable I don't think you can tell the difference between a read and a
> write without making some sort of wrapper around them.
> Still, I'd love to hear how you guys would do it.
> Thanks,
> -Sandra
> --

Endless the world's turn, endless the sun's spinning
Endless the quest;
I turn again, back to my own beginning,
And here, find rest.

More information about the Python-list mailing list