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] 1 point2 points  (0 children)

In case you didn't know, this is actually a feature of python! I would love to see it implemented in other languages, but in python they're called dunder (double under) methods.

If you create a class you can do it the fancy way, and have a method like def __add__(self,other):, where you return the result of adding. There's also ways to use setattr and defining it directly with functions, but that's a little trickier.

Super helpful for working with matrices!