[EMAIL PROTECTED] wrote: > [EMAIL PROTECTED] wrote: >> >> [EMAIL PROTECTED] wrote: >> >> > 1. return string names of required methods in getAllMethod >> > return ['method1', 'method2', 'method3'] >> > 2. use gettattr on self and then exetute methods in applyAll >> > def applyAll(self): >> > for method_name in self.getAllMethod(): >> > method = gettattr(self,method_name) >> > method() #execute method now >> >> why? > > ensure instance's method invocation with all state information to that > point, rather than relying on implemenation.
Erm, that makes no sense. The OP's code was perfectly fine - for some reason he seemed to think it wasn't. Your additional indirection doesn't add anything beyond clutter, as name = "foo" getattr(instance, name) == instance.foo holds. Diez -- http://mail.python.org/mailman/listinfo/python-list