Skip to content

Instantly share code, notes, and snippets.

@mcleonard
mcleonard / vector.py
Last active October 22, 2024 12:31
A vector class in pure python.
import math
class Vector(object):
def __init__(self, *args):
""" Create a vector, example: v = Vector(1,2) """
if len(args)==0: self.values = (0,0)
else: self.values = args
def norm(self):
""" Returns the norm (length, magnitude) of the vector """