[Python-Dev] operator precedence of __eq__, __ne__, etc, if both object have implementations

Chris Withers chris at simplistix.co.uk
Tue Sep 22 16:06:42 CEST 2009


Hi All,

I didn't see any docs on this:

http://docs.python.org/reference/datamodel.html?highlight=__eq__#object.__eq__

Where are the specifications on what happens if two objects are compared 
and both have implementations of __eq__? Which __eq__ is called? What 
happens if the first one called returns False? Is the second one called? 
What is one implements __eq__ and the other __ne__?

If I've missed something, please point me in the right direction.

To all those about to tell me to go read the source: that's not good 
enough here. I'm hoping there *are* "official" rules for how these 
interact and they just need better linking in, otherwise, I worry that 
IronPython could do one thing, Jython another and CPython a third...

cheers,

Chris

-- 
Simplistix - Content Management, Batch Processing & Python Consulting
            - http://www.simplistix.co.uk


More information about the Python-Dev mailing list