class Vector(object):
def __rmul__(self, other):
return self*other
def __mul__(self, other):
if hasattr(other, "elements"):
return sum(e1*e2
for e1,e2 in zip(self.elements, other.elements))
else:
s = [e*other for e in self.elements]
return Vector(*s)