For class definitions in Python, class Name(object) gets an argument of Object. On below code, I tried to use the class without having this argument "Object" and the code still works fine.
What is the purpose of having the object there? Does this have a special meaning in Python just like init does?
class Vector(object):
def __init__(self, coordinates):
try:
if not coordinates:
raise ValueError
self.coordinates = tuple(coordinates)
self.dimension = len(coordinates)
except ValueError:
raise ValueError('The coordinates must be nonempty')
except TypeError:
raise TypeError('The coordinates must be an iterable')
def __str__(self):
return 'Vector: {}'.format(self.coordinates)
def __eq__(self, v):
return self.coordinates == v.coordinates