About 1,530,000 results
Open links in new tab
  1. When should we avoid classes? : r/Python - Reddit

    Use a class when there isn't a data type in Python which fully expresses the thing you are trying to represent. For example, if I'm calculating someone's age, I would just use int, as it's fine for my needs.

  2. When to Write Classes in Python And Why it Matters

    Apr 25, 2020 · Avoid classes. With that said, OOP is not always the best solution. Here are some thoughts when to avoid classes: The most straightforward reason is if your class has just a constructor and one method. Then just use a function (and watch this great talk: Stop writing classes) Small (one off) command line scripts probably don’t need classes.

  3. When should I be using classes in Python? - Stack Overflow

    Oct 12, 2015 · In python the simple heuristic for when you should use a class comes down to whether or not your abstraction needs to be concerned with state. Abstractions that carry mutable state should be implemented using a class to express this.

  4. I avoid classes in Python. Am I bad? : r/learnpython - Reddit

    I sound similar to you but I wouldn't say I "avoid" using classes, just that I don't use classes unless I feel pretty certain to get a significant benefit out of it. There's a great talk I've linked below about when to use classes, and restraining the urge to immediately use classes for everything.

  5. You Don’t Need Classes in Python — Unless You Do

    Apr 16, 2025 · This article explores when you can skip classes in Python, when you should use them, and how to decide which approach fits your project. The Case Against Classes: Simplicity and...

  6. When should I not use classes in Python? - Stack Overflow

    Jul 12, 2017 · In Python specifically classes tend to be faster than using generic data structures but are more brittle: every dev and library knows how to work with lists and dicts but custom class APIs have to be learned and re-learned when they change (and boy do they change). Then you get into the whole inheritance vs composition discussion.

  7. When should I use classes and self method in Python?

    May 11, 2019 · Is it really necessary to use classes here or does it at least improve a program in any way? Classes are never necessary, but they are often very useful for organizing code. In your case, you've taken procedural code and just wrapped it in …

  8. When to create classes and when to avoid using classes in Python?

    Apr 5, 2021 · Use classes when particular functions have the same arguments. So, functions group together lines of code to prevent duplication. Classes group together related objects, which are easy to spot when they keep getting passed into functions together.

  9. Python minis 1: When to use Python Data classes - Medium

    Dec 30, 2024 · You should stop using regular classes in your code and start leveraging Python `dataclasses` for obvious use cases. It makes your life very simple. In this article we explore questions like:...

  10. You Don’t Need Classes in Python — Unless You Do

    Apr 16, 2025 · Python’s flexibility means you can often solve problems without the overhead of classes. Here are some reasons why you might avoid them: 1. Procedural and Functional Programming...

  11. Some results have been removed
Refresh