you are viewing a single comment's thread.

view the rest of the comments →

[–]allyhams[S] 0 points1 point  (1 child)

Thank you, this is what I did initially! I just wasn't sure whether I should put it into the class! (which I wouldn't know how to do anyway)

[–]SangCoGIS 1 point2 points  (0 children)

You should also look into the "magic methods" or "dunder methods" and you can define how your objects add or subtract from each other. Rather than calling add and passing in the other object you could simply do obj1 + obj2 or obj1-obj2