Congratulations! You rediscovered the well known fact that object orientation can be done without specific programming language support. It is basically the same way objects are introduced in Scheme in this classic text book. Note that Scheme does not have a class keyword or some kind of equivalent, and objects can be created without having even classes.

However, the object orientated paradigm was so successful that lots of languages - and Python is no exception - provide built-in support for it. This is simply to make it easier for developers to use the paradigm and to provide a standard form of object orientation for that language. It is essentially the same reason why lots of languages provide a for loop, though it could be emulated using a while loop with just one or two additional lines of code - simply ease of use.

Answer from Doc Brown on Stack Exchange
🌐
Quora
quora.com › Can-you-really-write-good-Python-code-without-using-classes-Would-it-be-a-bad-idea
Can you really write good Python code without using classes? Would it be a bad idea? - Quora
Answer (1 of 11): I have so many thoughts on this, I hope I can get at least some of them down in a sensible way. Hopefully it will be an enjoyable read, if somewhat long. You don’t create classes based on size. You create classes based on concepts and usage. When I first began programming in a...
🌐
Reddit
reddit.com › r/python › how to create classes without the class keyword
r/Python on Reddit: How to create classes without the class keyword
July 2, 2022 -

In Python, we learn that in order to create a class you need to start off with the `class` keyword. But the reality is that we actually don't.

I've written an article on how this works. We take a deeper dive into data types in Python and explore how they work under the hood.

I explore how all data types are classes, and how they can all be derived from `type` which by the way can do more than tell you the type of an object! Check out the article below if this sounds intriguing.

https://medium.com/@Salaah01/creating-a-class-in-python-without-the-class-keyword-67ce84bae22

Edit: Oh, and don't worry. The point of the article isn't to say. "Hey guys, this is a new way to write classes, and this is what you should do from now on". In the article, I explicitly discourage that. Instead, it's to give an inside to how it works and why it works.

🌐
Plain English
python.plainenglish.io › why-you-should-stop-using-classes-in-python-and-what-to-use-instead-855eeb914d68
Why You Should Stop Using Classes in Python — and What to Use Instead | by Mohab A.Karim | Python in Plain English
October 25, 2025 - While classes are compelling, classes are by no means the easiest to understand, nor are they the most clear method to express your code. In reality, many Python programmers (especially those coming from a functional and/or data-based perspective) have begun to transition away from OOP-based code structures.
🌐
Code with C
codewithc.com › code with c › blog › python without classes: exploring procedural python
Python Without Classes: Exploring Procedural Python - Code With C
January 28, 2024 - It’s all about keeping our variables in check and not letting them run amok. Who says we need classes to work with data structures? Not us! Arrays, tuples, and dictionaries can all be wrangled without the need for those pesky objects.
Top answer
1 of 6
64

Congratulations! You rediscovered the well known fact that object orientation can be done without specific programming language support. It is basically the same way objects are introduced in Scheme in this classic text book. Note that Scheme does not have a class keyword or some kind of equivalent, and objects can be created without having even classes.

However, the object orientated paradigm was so successful that lots of languages - and Python is no exception - provide built-in support for it. This is simply to make it easier for developers to use the paradigm and to provide a standard form of object orientation for that language. It is essentially the same reason why lots of languages provide a for loop, though it could be emulated using a while loop with just one or two additional lines of code - simply ease of use.

2 of 6
12

I would agree that the first definition satisfies the three points your teacher made. I do not think we need the class keyword for anything. Under the covers, what else is an object but a data structure with with different types of data and functions to work with the data? Of course, the functions are data as well..

I would go even further and say that doing object oriented programming is not so much dependent on the keywords your language provides, you can do object oriented programming in C if you so wished! In fact, the linux kernel employs such techniques.

What you can infer from the class keyword here is, that the language provides support for this kind of construct out of the box, and you do not need to through all the hoops to re-implement the functionality yourself(which is pretty fun task in itself!). Not to mention all the syntactic sugar you might get as well.

🌐
Reddit
reddit.com › r/learnpython › no need for classes
No need for classes : r/learnpython
April 28, 2023 - At the end of the day, all the structures that you use in Python are classes, and nothing would be possible without them.
🌐
Reddit
reddit.com › r/python › i've been using python for 3 years and i've never defined a class
r/Python on Reddit: I've been using Python for 3 years and I've never defined a Class
November 18, 2013 -

I consider myself a nearly advanced-level Python programmer. From data processing and statistical analysis to web development and systems administration of large clusters, I do it all regularly.

I started using it in grad school for my research and now use it everyday in my job as a computational scientist. However, I simply do not use classes. I use functions for everything, often many small functions whose output I feed into another. For large highly parallel data processing tasks, I'll have one main worker function that does the heavy lifting on each item that I'll pass to a multiprocessing Pool.

So my question is: Given that I know how to get stuff done quickly, what am I really missing out on or shorting myself on by never using classes?

Top answer
1 of 5
50
I can't say that I know the answer to your question, but I can give you my perspective. I am an astrophysicist who works with simulations and simulation data. Most of my work is fairly linear in nature meaning that I do A then B to get to C. I then proceed to plot C or do further data manipulation/reduction/etc. Early in grad school I picked up C as it was the language my adviser used; but that quickly got tiresome as I was always writing new code to output ASCII files for plotting. Once I started using python all of that changed since I could do the calculations and the plotting in the same place with simple scripts (no compilation) and results started to come a lot quicker. However, I was still doing things in a linear fashion and storing large arrays with multiple indexes to represent different properties. And it ended up that if I wanted to plot data from multiple simulations I had to save those arrays to a file (npz in my case) and remember all of my indexes and naming conventions. This became a pain when I started changing or adding things to those modules and the indexes/names changed. It wasn't until recently (August) that I discovered object-oriented programming and how to use it in python. I have since rewritten my entire analysis suite (that I spent the previous 6 months working on) to be object-oriented. Not only is my code cleaner, shorter, and easier to read/maintain/edit/add/subtract - it's much more user friendly. I can now plot multiple datasets with ease, and access information much quicker without having to write entire new scripts. I personally don't use methods very often in each of my classes, but having individual objects each with their own set of attributes has proved immensely helpful in my work. I like to think of the classes as python's structures. Anyway, hope that helps!
2 of 5
48
What kind of data structures do you find yourself using usually? Are you just implementing your own ad-hoc "classes" via dicts or lists?
Find elsewhere
🌐
Medium
medium.com › the-pythonworld › why-i-stopped-using-classes-in-python-and-what-i-use-instead-8805362111b5
Why I Stopped Using Classes in Python (And What I Use Instead) | by mata | The Pythonworld | Medium
September 23, 2025 - The new one was shorter, simpler to test, and didn’t need to instantiate a class in order to call one method. Python gives us so much expressiveness — we don’t need to reach for classes each time.
🌐
dbader.org
dbader.org › blog › 6-things-youre-missing-out-on-by-never-using-classes-in-your-python-code
6 things you’re missing out on by never using classes in your Python code – dbader.org
July 15, 2016 - I use functions and modules for everything, often many small functions whose output I feed into another. I simply don’t use classes because I never felt the need for them. ... I noticed that this is a common question for Python developers with a (data) science or numerical computing background.
🌐
Hacker News
news.ycombinator.com › item
Stop writing classes... | Hacker News
March 22, 2012 - 3DPoint = collections.namedtuple('3DPoint', ['x', 'y', 'z']) p1 = 3DPoint(3, 2, 4) p2 = 3DPoint(10, 1, 10) dist = math.sqrt((p2.x - p1.x)**2 + (p2.y - p1.y)**2 + (p2.z - p1.z)**2) I don't mean to say that classes aren't useful in Python, just that I've gotten a lot done in the language just ...
🌐
Python.org
discuss.python.org › python help
Classes are a bit overwhelming. How far can I get with just functions? - Python Help - Discussions on Python.org
May 8, 2025 - Right now, I find classes overwhelming and wanted to know: How far can I get by in python without classes? I know why they exist, but trying to think up when to use a class, is stressing me out a bit. I’m probably more used to the ideas of procedural programming like C, so I can think better if I just break everything up into functions.
🌐
Reddit
reddit.com › r/askprogramming › testing in python without classes?
r/AskProgramming on Reddit: Testing in python without classes?
June 23, 2021 -

I'm a brand new python dev (actually a new dev altogether) and I'm trying to understand testing in python. My university testing was limited, only did a single unit on it in a single course and it was in a single language, so my understanding of testing in general is quite limited, especially in python which is a new language for me.

From what I understand, the way most testing works by default in python (with the built in unittest library) is using classes. I guess you run tests on methods that are part of classes (as opposed to classless functions).

The issue is, the project I'm working on at work isn't object oriented. We don't actually use classes. Which honestly is fine, object oriented has its benefits but sometimes its exhausting. So I wasn't complaining that we weren't taking an object oriented approach. but now i'm finding testing... challenging.

Is there a way to do testing without having things in a class? For now, all I can think to do is put everything inside a dummy class, wrap parts in static methods for testing, then comment out all the class specific codes after i'm done testing.

surely there's a way to do unit tests without classes?

Also, I'd rather keep to the default unittest library if possible. i understand there may exist other unit testing libraries/modules/packages inside python but my work generally wants me to avoid adding new dependencies.

Thanks for the help.

Top answer
1 of 1
3

Python with or without classes is Turing complete, so there isn't going to be any application that can only be written with or without them. Additionally python provides collections.namedtuple so if all you wanted was groups of attributes (equivalent of a C struct) you could use that instead.

Therefore you are really left with the distinction between procedural programming (C struct style) and full OOP (classes with methods being part of the class).

Therefore, I think your question just morphs into:

What are the benefits of OOP?

Listing the bullet points that is:

  • Encapsulation.
  • Abstraction.
  • Polymorphism
  • Inheritance (okay some people wouldn't call that a benefit)

In python when is absolutely preferable use a class than a module?

When one or more of the OOP attributes listed above, are useful for the problem you are trying to solve.


As a more practical matter I don't use classes much in python and when I do it's usually just a scoping tool: I have a bunch of long running state (that isn't global), I initialize a class and throw the state into member variables of the class. When methods in the class call other methods they don't need long parameter lists, since they can all just access the state at the class level.

I could achieve the same result simply by nesting functions inside other functions, but my history is similar to yours and nesting functions is not always the first solution I think of.

In python I have found I have to give a bit more thought to how I want to separate my code so that I can test it effectively. Thats probably a good thing - but in Java it's not something you have to give much thought to, due to the prevalence of Classes (everything is a class) and very good Mock and DI frameworks. In short in Java you just decide what you want to mock and the frameworks pretty much take care of it, without you having to change your production code.

🌐
Plain English
python.plainenglish.io › creating-a-class-in-python-without-the-class-keyword-67ce84bae22
Create a Class in Python Without the Class Keyword | by Salaah Amin | Python in Plain English
July 6, 2022 - We will explore how you can create a class in Python without using the class keyword. Whilst this exploration you will learn what a class another all other data types are really under the hood.
🌐
Reddit
reddit.com › r › Python › comments › 84i0pm › classes_without_classes
r/Python - Classes without Classes
March 15, 2018 - Every now and again I start to think I'm really beginning to get to grips with Python, and then I find an article like this... ... Op · 5 yr. ago ... This is basically abuse of the object model and closures; they have real code usages but very rarely come up outside of working around things, so don't sweat it, you'll be fine without learning this.
🌐
Stack Overflow
stackoverflow.com › questions › 47722336 › how-can-i-make-this-function-without-classes-python-3-tkinter
How can I make this function without classes - Python 3 Tkinter - Stack Overflow
That's understandable. When I started like this my reasoning was that tkinter would be tricky enough without having to learn about classes, too. As it turns out, all you really need to know about classes here is to use self and that self.variable can be used anywhere the class and persists outside the methods that create them.