[Python-Dev] Inplace multiply
Paul Dubois
paul@pfdubois.com
Tue, 13 May 2003 10:25:38 -0700
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.