learning python atm, and i found this on vectors
CODE
class Vector:
def __init__(self, data):
self.data = data
def __repr__(self):
return repr(self.data)
def __add__(self, other):
data = []
for j in range(len(self.data)):
data.append(self.data[j] + other.data[j])
return Vector(data)
def __sub__(self, other):
data = []
for j in range(len(self.data)):
data.append(self.data[j] - other.data[j])
return Vector(data)
you can then do somthing like this
CODE
x = Vector([1.0, 2.0, 3.0])
y = Vector([2.0, 2.0, 2.0])
print x + y,
#or
print x - y,
depending on what else you want to do u need to add more lines of code to the class