Don't work __getattr__ with __add__

Andrey Simurzin asimurzin at gmail.com
Thu Mar 4 03:54:13 EST 2010


On 4 мар, 11:38, Chris Rebert <c... at rebertia.com> wrote:
> On Thu, Mar 4, 2010 at 12:25 AM, Андрей Симурзин <asimur... at gmail.com> wrote:
> > It is object of the class A, in conteiner's class tmpA. Not all method
> > from A are in the tmpA. So for exapmle:
> > A + B -- yes , tmpA + B no. I try to call method from A for tmpA. I
> > can to call simple method,  such as change(), bit __add__ -  don't
> > work. If to remove inheritance from object, the code work's. Help me,
> > please
>
> Some clarity has been lost in translation, but I think I get what you're saying.
> __add__ and the other double-underscore special methods are not looked
> up using __getattr__ or __getattribute__, hence trying to do addition
> on tmpA, which does not define an __add__ method, fails.
>
> For a full explanation, read:http://docs.python.org/reference/datamodel.html#special-method-lookup...
>
> Cheers,
> Chris
> --http://blog.rebertia.com

Thank you very much



More information about the Python-list mailing list