I've been learning Python for about two weeks and recently updated my MiniGameStore project to use classes. Learning the class syntax itself was manageable, but adding class methods created several problems with variables, imports, and a JSON file when I tried to build a restore-purchases feature in version 1.7.0. At that point, I wondered whether a regular function would have been simpler and whether I was introducing classes too early.
I'd like to understand what helped other people really grasp classes and object-oriented programming. When are classes genuinely more useful than dictionaries and functions? Is my Game class a reasonable use of a class, and what would be a practical, real-world way to structure the project? I'd also like to know why classes are often placed in separate files and what problems global variables can cause. Constructive feedback on the project's design is welcome.
4 Answers
Keeping a class in a separate file is mainly about organization, not a Python requirement. Once a class becomes substantial or is used by several parts of the program, separating it keeps each file focused and makes the code easier to navigate. For a tiny project, putting a few related definitions in one file is completely fine. Global variables can also work in small scripts, but they make it harder to track where values change and can cause unrelated functions to depend on hidden state. Passing values explicitly or keeping state inside an object usually makes the program easier to reason about.
Your Game class sounds like a reasonable use of a class. It represents one thing with its own data and operations, which is the basic situation where classes fit naturally. You could also look into Python’s dataclass decorator if the class mostly stores related values. It can generate the initializer automatically and reduce boilerplate.
A good way to understand classes is to use libraries that require them. Object-relational mapping tools are a common example: you define classes in a particular way, and the library provides useful behavior such as database interaction automatically. That makes the relationship between an object’s data and its methods more concrete than studying class syntax in isolation.
You don’t strictly need classes. A procedural or functional design can work perfectly well, especially for a small project. Classes become useful when you want to group related data and behavior together, hide implementation details, or create multiple independent objects with the same structure. They can make a program easier to read and maintain, even if they sometimes add more structure than the project currently needs.
They can also make code more modular and easier to test. If a class has one clear responsibility, it can often be reused or moved into another project with very little change.

I understand the concern that a dictionary plus a function might work just as well here. That’s true for a small program. The advantage of a class usually becomes clearer as the object gains more related behavior or when you need to create many similar objects, so don’t force the design before you need it.