From: Frank T. <ft...@ne...> - 2003-02-26 21:32:41
|
Adrien Di Mascio, on 2003-02-26, wrote: > What I would like to do is to check when "self.l" is changed > (self.l.append() or self.l.pop() or ...) . I tried to add a > "self.before('setattr', 'l', self.list_changed)" but it didn't work. A 'setattr' of attribute L on object O is not the same as that attribute 'changing', e.g., by o.l.append(), o.l.pop(). I think the only way you could approach the problem you want to solve with Pythius is to have the L attribute itself (and not its 'holder') subclass the class 'list' and be the 'aspectified' object and have a bunch of statements that cover each 'modifying' method such as: self.after('method_call', 'pop', self.i_changed) self.after('method_call', 'append', self.i_changed) Other than that, there's no real way for the 'holder' of L to know that an attribute of itself has changed values, especially if you started doing things like: l2 = o.l l2.append('foo') # this changed o.l Sorry that's there's no easy answer to your question :( -- Frank Tobin http://www.neverending.org/~ftobin/ |