I have this mul method which decides if its scalar multiplication or matrices multiplication(or an error), it works for scalars and matrices as it should but also for strings and lists (else doesn't executed). how can i fix that?
def __mul__(self, other):
if type(other) is Matrix:
return self.matrices_mul(other)
elif type(other) is float or int:
return self.scalar_mul(other)
else:
raise SyntaxError("invalid input")
Aucun commentaire:
Enregistrer un commentaire