matrix_1 = matrix_2 * matrix_3
Anton Vredegoor
anton at vredegoor.doge.nl
Mon Aug 26 12:21:12 EDT 2002
On Mon, 26 Aug 2002 16:05:30 +0200, holger krekel <pyth at devel.trillke.net>
wrote:
>Do know how easy it is in python to redefine the star operator?
>
>>>> class a(str):
>... def __mul__(self, other):
>... return self.startswith(other) or other.startswith(self)
>...
>>>> a1=a("hallo")
>>>> a2=a("hal")
>>>> a1*a2
>1
>
>So you could inherit whatever matrix-class you like and (re)define
>the __mul__ operator to mean 'matrixmultiply'.
>
>Ask back if you don't know what i am talking about :-)
Ok, I am asking :-)
Anton.
>>> class myarray(Numeric.array):
def test(self):
pass
Traceback (most recent call last):
File "<pyshell#19>", line 1, in ?
class myarray(Numeric.array):
TypeError: cannot create 'builtin_function_or_method' instances
More information about the Python-list
mailing list