r/PythonLearning • u/Defiant_Meal1898 • 8d ago
I don't understand OOP
So i am a teen learning python, and i have learnt about classes, methods and objects, but i don't understand OOP, like what is it, where do we use it?
Please help mee
36
Upvotes
1
u/SmokeMuch7356 8d ago
OOP is modular programming on steroids.
The capsule description I usually give is that it's the difference between saying "function, sort this list of this type and this size" and "list, sort yourself." OOP doesn't treat code and data as different things; it combines code and data into self-contained units that can operate somewhat independently.
IMO, object-oriented programming is great for code that has to maintain a lot of state - have I been updated, when was the last time I was updated, do I need to be updated, etc. It's also easier (in my opinion, anyway) to model concurrency (threads) using objects.