Help in using introspection to simplify repetitive code

Fredrik Lundh fredrik at pythonware.com
Mon Aug 21 05:40:27 EDT 2006


jsceballos at gmail.com wrote:

> And they do take arguments, and a variable number of them, so AFAIK
> hooking with __getattr__ or __getattribute__ will not work, as you can
> only get the method name with that.

why not just return the bound method *object* (a callable), and let the 
caller call that as usual (see Terry's last example).

(hint: x.foo() can be written f=getattr(x,"foo"); f())


</F>




More information about the Python-list mailing list