Is 'everything' a refrence or isn't it?
Bengt Richter
bokr at oz.net
Mon Jan 16 05:34:40 EST 2006
On 15 Jan 2006 13:50:14 -0800, Paul Rubin <http://phr.cx@NOSPAM.invalid> wrote:
>Mike Meyer <mwm at mired.org> writes:
>> > I'd say a==b doesn't necessarily mean a and b have the same value.
>> Care to say what it does mean (as opposed to what it doesn't mean), then?
>
>a==b simply means that a.__eq__(b) returns True.
That's one possibility, but I guess __eq__ might not necessarily
even have to be defined (too lazy to set up the new-style class test ;-):
>>> 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
Regards,
Bengt Richter
More information about the Python-list
mailing list