<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello. > I'm writing a proxy class, i.e: a class whose methods mostly delegate > their functionality to other class object. Most of the methods (which > are quite a lot) defined in the class would end up being: > > def thisIsTheMethodName(self): > self._handlerClass.thisIsTheMethodName()
Are these parameterless static methods or should this be self._handlerClass.thisIsTheMethodName(self) or does self get auto-bound even though not a _handlerClass instance? (I have never needed or done such delegation.) > The handler object is the same in all methods. > > I was wondering if there is a way to simplify this proxy class, maybe > using some pythonic technique like metaclasses, introspection... any > suggestion is appreciated. My immediate thought would be to start with _forwarded = set(......) # of forwarded method names def __getattr__(self, name): if name in _forwarded: return getattr(self._handlerClass, name) but I am not sure if this gives the right wrapping and binding. Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list