How is the operator overloading parsed? I have a class object o and want to do -1 * o with the overloaded __mul__ operator. Would that be parsed correctly when the left operand is a -1? Multiplication should be commutative (except for matrices and cross-products)... ?
2 Answers
Operators are always parsed the same way regardless of overloading. Because unary - has higher precedence than *, -1 * o will always be parsed as (-1) * o.
1 Comment
BrenBarn
I don't think that is what the OP is getting at, although his use of "parsing" may misleadingly suggest it.
__mul__, not__mult__.