[Python-Dev] Inplace multiply (original) (raw)

Guido van Rossum guido@python.org
Tue, 13 May 2003 13:44:37 -0400


My "masked array" class MA has a problem that I don't know how to solve. The inplace multiply function

def imul (self, other) is not getting called while my other input operations do work. The scenario is x = MA.array(...) x *= c If c is an int, this works correctly, calling MA.imul. Otherwise, I get a message from the Python runtime saying it can't multiply a sequence by a non-int. But change MA to Numeric, it works. Numeric is an extension type and MA is a (new style) class. MA defines len as well as all the math operators.

We won't be able to help without seeing your code.

--Guido van Rossum (home page: http://www.python.org/~guido/)