super, decorators and gettattribute

Richard Szopa ryszard.szopa at gmail.com
Sat Jan 12 17:23:52 EST 2008


On Jan 12, 9:47 pm, Mike Meyer <mwm-keyword-python.b4b... at mired.org>
wrote:

> The same way you call any object's methods if you know it's name":
>
>     getattr(super_object, name)(*args, **kwargs)

Thanks a lot for your answer!

However, I am very surprised to learn that

super_object.__getattr__(name)(*args, **kwargs)

getattr(super_object, name)(*args, **kwargs)

are not equivalent. This is quite odd, at least when with len()
and .__len__, str() and .__str__. Do you maybe know what's the
rationale behind not following that convention by getattr?

Best regards,

    -- Richard



More information about the Python-list mailing list