[docs] [issue12067] Doc: remove errors about mixed-type comparisons.

Ezio Melotti report at bugs.python.org
Fri Dec 2 17:49:28 CET 2011


Ezio Melotti <ezio.melotti at gmail.com> added the comment:

Would it be ok to state that:
1) <, >, ==, >=, <=, and != compare the values of two objects;
2) the two objects don't necessarily have to be of the same type;
3) with == and !=, objects of different types compare unequal, unless they define a specific __eq__ and/or __ne__;
4) with <, >, <=, and >=, the comparison of objects of different types raises a TypeError, unless they define specific __lt__, __gt__, __le__, and __ge__;
5) some built-in types define these operations, so it's possible to compare e.g. int and floats;

This should summarize the possible behaviors.  There's no reason IMHO to expose implementation details and to special case built-in types (unless their comparison is actually different and doesn't depend on __eq__, __ne__, etc.).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12067>
_______________________________________


More information about the docs mailing list