Operator Overload! Learn how to change the behavior of equality operators.

By: Mark Mruss

Note: This article was first published the November 2007 issue of Python Magazine

While the equality operator works great on numbers and strings the fact the way it treats your custom objects really is not that useful. This article looks into overloading the equality operator so that you can easily compare your custom classes.

  1. Introduction
  2. Introducing the terms: operators and operator overloading
  3. A Quick Example of the Default Equality Operator
  4. Overloading the Equality Operator
  5. Telling Python that the Comparison has Not Been Implemented
  6. The Inequality Operator
  7. Dangers
  8. Conclusion

Continue reading Operator Overload! Learn how to change the behavior of equality operators.