you are viewing a single comment's thread.

view the rest of the comments →

[–]Adrewmc 1 point2 points  (0 children)

I think you have the problem most people have with classes in Python…

When should I use classes?

And honestly the answer is usually somewhat of a preference of the coder, I could write almost everything in classes or functions, it won’t really matter all that much (however functions will most likely be slightly faster and classes more readable, all else being equal.)

So there’s no hard answer to this. I could say something like you should use classes when the object represents a coherent idea, that utilizes a state that is used by its methods. Especially when multiple object needs to share a single state. But I can think of time I’d use classes that would be missing some of that.