Is 'everything' a refrence or isn't it?

Steven D'Aprano steve at REMOVETHIScyber.com.au
Mon Jan 16 05:58:26 EST 2006


On Mon, 16 Jan 2006 10:34:40 +0000, Bengt Richter wrote:

>  >>> class A:
>  ...     def __getattr__(self, attr): print 'A().%s'%attr; raise AttributeError
>  ...
>  >>> class B:
>  ...     def __getattr__(self, attr): print 'B().%s'%attr; raise AttributeError
>  ...
>  >>> A()==B()
>  A().__eq__
>  B().__eq__
>  B().__eq__
>  A().__eq__
>  A().__coerce__
>  B().__coerce__
>  A().__cmp__
>  B().__cmp__
>  False

Why are A().__eq__ and B().__eq__ both being called twice?


-- 
Steven.




More information about the Python-list mailing list