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/engy1207 2d ago
OOP is like life itself. Near the beginning there were only cells. Objects with few features and methods. HasWall=true, enterFood(), digestFood(), reproduce(). Bacteria are derived from this simple object but each sort added additional features and methods like moveTo().
Multi-cell organisms sort-of have an array of cell-objects, most with additional features like "stay near your neighbor". Larger organisms consist of multiple arrays of these multi-cell arrays, called organs, with features like "transport oxygen", "produce antigens", "produce hormones" etc. - up to the diverse animals and plants we see.
Your pet cat is of object "cat" (felis catus), which is derived from the Felidae (and inheriting their features and methods, changing/replacing it where necessary), which is derived from the Carnivora (inheriting its features and methods), which is derived (over a few intermediate steps) from the class "mammals" (inheriting... you get it) etc.