Re: Creating an object that can track when its attributes are modified

2013-03-07 Thread Schneider
Hi, maybe you could do this by a decorator on the setattr method. It should look more or less like your implementation, but in my eyes it's a cleaner and can be reused. Further, I would use a stack for each attribute, so that you can restore all previous values. bg, Johannes On 03/06/2013 0

Re: Creating an object that can track when its attributes are modified

2013-03-06 Thread Ben Sizer
On Thursday, 7 March 2013 00:07:02 UTC, Steven D'Aprano wrote: > On Wed, 06 Mar 2013 08:56:09 -0800, Ben Sizer wrote: > > > I need to be able to perform complex operations on the object that may > > modify several properties, and then gather the properties at the end as > > an efficient way to se

Re: Creating an object that can track when its attributes are modified

2013-03-06 Thread 88888 Dihedral
Ben Sizer於 2013年3月7日星期四UTC+8上午12時56分09秒寫道: > On Wednesday, 6 March 2013 16:22:56 UTC, Chris Angelico wrote: > > > > > > Effectively, you would need to have a > > > subclass of list/dict/tuple/whatever that can respond to the change. > > > > This is certainly something I'd be interested in

Re: Creating an object that can track when its attributes are modified

2013-03-06 Thread Chris Angelico
On Thu, Mar 7, 2013 at 3:56 AM, Ben Sizer wrote: > On Wednesday, 6 March 2013 16:22:56 UTC, Chris Angelico wrote: >> >> Effectively, you would need to have a >> subclass of list/dict/tuple/whatever that can respond to the change. > > This is certainly something I'd be interested in having, but I

Re: Creating an object that can track when its attributes are modified

2013-03-06 Thread Lele Gaifax
Ben Sizer writes: > I also believe that this won't catch modification to existing > attributes as opposed to assignments: eg. if one of the attributes is > a list and I append to it, this system won't notice. Is that something > I can rectify easily? It's really up to how far you wanna go: a sim

Re: Creating an object that can track when its attributes are modified

2013-03-06 Thread Ben Sizer
On Wednesday, 6 March 2013 16:22:56 UTC, Chris Angelico wrote: > > Effectively, you would need to have a > subclass of list/dict/tuple/whatever that can respond to the change. This is certainly something I'd be interested in having, but I guess that would be fragile since the user would have t