Interesting problem - can it be done

Alex Martelli aleax at
Thu Aug 9 11:31:44 CEST 2001

"Erik Max Francis" <max at> wrote in message
news:3B722A4C.F8D9005C at
> methods = ['method1', 'method2', 'method3']
> for method in methods:
>     value = apply(getattr(testobj, method), ())

Good, but there's no reason not to spell the last line:

        value = getattr(testobj,method)()

Entities should not be multiplied without necessity,
and the apply here is really doing nothing.


More information about the Python-list mailing list