Help in using introspection to simplify repetitive code

jsceballos at gmail.com jsceballos at gmail.com
Sun Aug 20 12:20:45 EDT 2006


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()

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.

Thanks,

Javier Sanz




More information about the Python-list mailing list