Overloading operators

Mr.SpOOn mr.spoon21 at gmail.com
Wed Oct 15 14:34:14 CEST 2008

in a project I'm overloading a lot of comparison and arithmetic
operators to make them working with more complex classes that I

Sometimes I need a different behavior of the operator depending on the
argument. For example, if I compare a object with an int, I get a
result, but if I compare the same object with a string, or another
object, I get another result.

What is the best way to do this? Shall I use a lot of "if...elif"
statements inside the overloaded operator? Or is there a more pythonic
and dynamic way?

More information about the Python-list mailing list