Sitemap

The Pythonworld

Become a Better Python Developer

Press enter or click to view image in full size
Photo by Monica Toner on Unsplash

Why I Stopped Using Classes in Python (And What I Use Instead)

After years of writing class-based Python code, I realized simpler tools often get the job done better. Here’s what I switched to — and why you might want to as well.

3 min read3 days ago

There was a day when I enclosed everything in classes.
It seemed the “professional” thing to do. I mean, object-oriented programming (OOP) was the be all and end all, wasn’t it?

But after having developed APIs, automation scripts, and data pipelines for real-world products, I came up with a conclusion: I didn’t need classes as much as I thought.

In fact, classes in the majority of projects were inhibitive.

Show me.

The Class Obsession (And Where It Came From)

We all learned classes are the secret to clean, scalable code.
You’re taught about init, about inheritance, about encapsulation — and before you know it, you’re building complex class hierarchies for every little task.

I did likewise. My code was full of boilerplate like:

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web
Already have an account? Sign in
The Pythonworld
Aashish Kumar
Aashish Kumar

Written by Aashish Kumar

Hi, I’m Aashish Kumar, a passionate software engineer from India 🇮🇳, specialize in Python | Django | AI | LLM | Full Stack Development.

No responses yet

Write a response