how to detect change of list of instances

Bruno Desthuilliers bruno.42.desthuilliers at wtf.websiteburo.oops.com
Wed Mar 14 05:09:20 EDT 2007


manstey a écrit :
> Thanks.
> 
> All I want to know is whether the newlist, as a list of instances, is
> modified. I thought equality was the way to go, but is there a simpler
> way? How can I monitor the state of newlist and set a flag if it is
> changed in anyway?

<thinking-out-loud>
Override the mutators - or just wrap them in a decorator. But I don't 
know if it's "simpler". And FWIW, it won't catch modifications of 
contained objects - only modifications of the list itself. So you'd also 
need to wrap contained objects in an object that would itself detect all 
changes and notify the container. Err... Looks like equality is the way 
to go.
</thinking-out-loud>



More information about the Python-list mailing list