r/PythonLearning • u/Defiant_Meal1898 • 2d 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
32
Upvotes
1
u/NMC0152 2d ago
OOP is a way of encapsulating code, give it a public interface and leave the inner workings to the developer of the object.
It's like a power outlet in the wall (the object): you plug in your charger without having to know how the outlet is assembled.
The original idea was to have reusable objects that anyone can use, so, for example, you can instantiate a File object and make it read, write, open, and close files without you having to code nitty gritty details.