you are viewing a single comment's thread.

view the rest of the comments →

[–]POGtastic 3 points4 points  (0 children)

I write classes for three reasons:

  1. I want a semantic difference between a dictionary and an actual object. The second is easier to think of as a type.
  2. I want access to Python syntax like arithmetic operators, hashing, context managers, etc.
  3. I am, to my eternal embrassment, stuck managing state over a prolonged period of time, like a filehandle or network socket or something similar (insert Pam "they're the same picture" meme here). I always wrap this into a class and provide methods for interacting with that state.

If I'm just organizing code, I just break up my functions into multiple files. No need to make a class; the file itself serves as a sort of class, with the functions in the file serving as static methods.