matrix_1 = matrix_2 * matrix_3

holger krekel pyth at devel.trillke.net
Mon Aug 26 21:01:41 CEST 2002


Anton Vredegoor wrote:
> 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 :-)

Only if Fernando's much better path doesn't work i am going to answer :-)

have fun,

    holger




More information about the Python-list mailing list