super, decorators and gettattribute

Richard Szopa ryszard.szopa at gmail.com
Sun Jan 13 07:51:20 EST 2008


On Jan 13, 8:59 am, Marc 'BlackJack' Rintsch <bj_... at gmx.net> wrote:
> On Sat, 12 Jan 2008 14:23:52 -0800, Richard Szopa wrote:
> > 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?
>
> I think you are confusing `__getattr__` and `__getattribute__` here!
> `getattr()` maps to `__getattr__()`, it's `__getattribute__` that's
> different.

Well, in my code calling super_object.__getattr__(name)(*args,
**kwargs) and getattr(super_object, name)(*args, **kwargs) gives
*different* effects (namely, the latter works, while the former
doesn't). That kinda suggests that they don't map to each other :-).
And that makes me feel confused.

Cheers,

    -- Richard




More information about the Python-list mailing list