Re: [Tutor] Defining operators for custom types

2010-02-12 Thread Mark Young
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:

Re: [Tutor] Defining operators for custom types

2010-02-12 Thread bob gailer
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

[Tutor] Defining operators for custom types

2010-02-12 Thread Mark Young
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