jcalderone: How to override comparison operators in Python - 0 views
-
here are the basic rules for the customization of ==, !=, <, >, <=, and >=: For all six of the above operators, if __cmp__ is defined on the left-hand argument, it is called with the right-hand argument. A result of -1 indicates the LHS is less than the RHS. A result of 0 indicates they are equal. A result of 1 indicates the LHS is greater than the RHS
-
__eq__ is not used for !=
-
For <, __lt__ is used. For >, __gt__. For <= and >=, __le__ and __ge__ respectively
- ...1 more annotation...
-
here are the basic rules for the customization of ==, !=, , =: For all six of the above operators, if __cmp__ is defined on the left-hand argument, it is called with the right-hand argument. A result of -1 indicates the LHS is less than the RHS. A result of 0 indicates they are equal. A result of 1 indicates the LHS is greater than the RHS.