Thanks for the help. That's exactly the kind of solution I wanted. I've been
to that page several times already, but just ignored that section
apparently. Thanks alot.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
Mark Young wrote:
I created a custom vector type, inheriting from object, and defined
__mul__, __add__, etc. Unfortunately, the operators only work if I
type "vector * (int/float/number)", in that exact order. My program
produces an error if I instead type "number * vector".
Use __rmul__, __r
I created a custom vector type, inheriting from object, and defined __mul__,
__add__, etc. Unfortunately, the operators only work if I type "vector *
(int/float/number)", in that exact order. My program produces an error if I
instead type "number * vector". This makes sense to me, because I haven't