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

Nick Coghlan ncoghlan at gmail.com
Wed Sep 23 14:05:29 CEST 2009


Mark Dickinson wrote:
> On Tue, Sep 22, 2009 at 3:37 PM, Chris Withers
> <chris at simplistix.co.uk> wrote:
>> 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__?
> 
> I (still :-) think this is covered, for Python 2.x at least, by:
> 
> http://docs.python.org/reference/datamodel.html#coercion-rules

Quite some time ago, I attempted to accurately document all of this - my
efforts are buried in an ODF document in the SVN sandbox:

http://svn.python.org/view/sandbox/trunk/userref/ODF/Chapter02_StatementsAndExpressions.odt

Extracting all of that text with some kind of ODT2ReST converter has now
been on my to-do list for over a year :P

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------


More information about the Python-Dev mailing list