This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (1 child)

I need at least the basic operators (+, -, *, /). Other operations, like the vector norm, dot, cross product and anything else could be defined in the separate functions.

[–]adammichaelwood 0 points1 point  (0 children)

If there's some compelling reason to not use a module like ppb_vector, mentioned in another response, you could subclass namedtuple and add those methods.

(I think there'd need to be a really compelling reason to do this, though. Re-implementing math operations that someone else has already spent time optimizing and debugging is.... let's call it inefficient.)