[Python-Dev] operator precedence of eq, ne, etc, if both object have implementations (original) (raw)

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


Jared Flatow wrote:

This might help:

http://mail.python.org/pipermail/python-dev/2008-June/080111.html Here is the most relevant part (quoting Guido): > Does it help if I tell you that for "x y" we always try > x.binop(y) before trying y.reversebinop(x), except in the > case where y is an instance of a subclass of the class of x?

Okay, but does that count as a pronouncement that should go across all versions and platforms?

I believe there are differences between when eq and ne are called between Python 2 and 3, and I don't see any docs on the expected behaviour for python 2, dunno about 3.

I'm willing to write these docs, http://docs.python.org/reference/datamodel.html#object._eq_ feels like the right place, is there anywhere else they should go or be linked to from?

Mark Dickinson gave some useful insights into this, and Milko Krachounov provided these useful comparisons on #python:

Python 2 http://pastebin.com/f8f19ab3

Python 3 http://pastebin.com/f55e44630

Do they cover it all or has anything been missed?

cheers,

Chris

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



More information about the Python-Dev mailing list