[Python-Dev] operator precedence of eq, ne, etc, if both object have implementations (original) (raw)
Chris Withers chris at simplistix.co.uk
Wed Sep 23 10:12:21 CEST 2009
- Previous message: [Python-Dev] operator precedence of __eq__, __ne__, etc, if both object have implementations
- Next message: [Python-Dev] operator precedence of __eq__, __ne__, etc, if both object have implementations
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Mark Dickinson wrote:
I (still :-) think this is covered, for Python 2.x at least, by:
http://docs.python.org/reference/datamodel.html#coercion-rules
But this isn't coercion! :-)
- For objects x and y, first x.op(y) is tried. If this is not implemented or returns NotImplemented, y.rop(x) is tried.
Also, the above is not so:
Python 2.5.1
class X: ... def eq(self,other): ... print "X eq" class Z: pass ... Z()==X() X eq
No req in sight...
cheers,
Chris
-- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk
- Previous message: [Python-Dev] operator precedence of __eq__, __ne__, etc, if both object have implementations
- Next message: [Python-Dev] operator precedence of __eq__, __ne__, etc, if both object have implementations
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]